3

I am trying to add a few files to .gitignore, but not having luck:

# -- in my .gitignore file --

# other items
settings_staging.py
settings_production.py

And to test it I'm doing:

$ git check-ignore settings_staging.py

I know my .gitignore is working and including some files, such as the __pycache__ files, but how do I get it to ignore particular files I specify?

Incidentally, if I change the name of the file to staging.py and use the following, it works in the gitignore:

*staging.py    

$ git check-ignore staging.py
staging.py
David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    What do you mean by "not having luck"? If you want to ignore files that are already tracked you have to tell git that these files should be deleted from source control `git rm --cached setting_staging.py` – Håken Lid Oct 10 '18 at 18:04
  • @HåkenLid oh, got it -- this is the correct answer. If you want to put this in an answer I'll go ahead and answer it -- thanks for the help. – David542 Oct 10 '18 at 18:05
  • I'll mark it as a duplicate instead. You're not the first person that had this problem. – Håken Lid Oct 10 '18 at 18:06
  • Note that when you use `git rm --cached` you are setting yourself up for future pain: see https://stackoverflow.com/q/52743969/1256452 – torek Oct 10 '18 at 20:16

0 Answers0