3

I have a rule to ignore secret.py (production.py in my case) and once I added .gcloudignore, github stopped following that rule... Is there some sort of a rule overriding between gitignore and gcloudignore that I am not aware of?

my-project/
    .git
    .gitignore
    my-project/
        .gcloudignore
        settings/
            base.py
            local.py
            production.py

my .gitignore:

my-project/my-project/settings/production.py
my-project/my-project/settings/local.py

my .gcloudignore:

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

*.sqlite3
settings/local.py

End result is that the 'local.py' is NOT pushed to google cloud NOR github. However, 'production.py' IS pushed to github AND gcloud.

willer2k
  • 506
  • 1
  • 6
  • 17

2 Answers2

1

If you had previously (perhaps accidentally) submitted a change to git that included my-project/my-project/settings/production.py, then it will remain a part of the repository even if it is subsequently added to .gitignore.

Assuming you are at the root of your project, you can use

$ git log my-project/my-project/settings/production.py

to see its git history. If it is present in your repo, you can do

$ git rm --cached my-project/my-project/settings/production.py

to remove it from the repo, but keep it in your local (working) environment.

Myk Willis
  • 12,306
  • 4
  • 45
  • 62
0

Looks like you are enforcing to ignore the rules applied before.

Though make sure that the cloudignore is enable via

gcloud config set gcloudignore/enabled true

And make sure to place .gcloudignore - > in the root of your project / basically where you .git .gitignore reside.

Afelaia Timur
  • 51
  • 1
  • 4
  • The issue is that gcloud's ignore file is working fine. It's the git ignore file that isn't following the ignore rule. I guess the question is 'why are gitignore and gcloudignore interfering with each other at all?' Shouldn't they be completely disjoint? – willer2k May 13 '20 at 15:36