It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to "force" ignore a file?

Marcos Hernández Oct 02, 2013

I have this .gitignore:

django-countries/*
data.db
myproject/settings.py
myproject/wsgi.py
*.pyc

I need to ignore myproject/settings.py because they're different in the development environment and the production environment but git still tracks the file. I tried to ignore it in sourcetree but the option appears inactive. Any Ideas?

2 answers

1 accepted

1 vote
Answer accepted
Marcos Hernández Oct 03, 2013

I found the answer here http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring

Basically clean the index and cache, then ignore the file

0 votes
Mladen B Oct 02, 2013

You should check if your .gitignore file is being read at all or not. It could be that there exists a global gitignore or a custom-specified git ignore file, specified on the command line, when the git runs. However, try adding a line like:

myproject/settings2.py

to your .gitignore and of course create that file, just to make sure that .gitignore file is being respected.

If everything is ok with your .gitignore file, than it might be the case where the git has already tracked/staged/pushed some previous versions of that file, so you might want to remove it from the remote git repository too. For that purpose, try using:

git rm myproject/settings.py

(don't forget to backup your file first, since that command will remove the local copy of the file also). After that, push your changes and just create a new file myproject/settings.py and it shouldn't be tracked any more (according to .gitignore).

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Off-topic

Disney Live Action Reboots: Are you for or against?

Happy Friday Everyone! Today marks the international release of Disney's live action version of the animated classic Aladdin. I know that this movie was met with some controversy of over cast...

140 views 19 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you