Why is git still tracking files with extensions already added to the .gitignore file

I am having problems with data.sqlite and members / model.pyc . This is what my .gitignore file looks like. If the above files appear to be modified, does git still track them correctly? These files have not been tracked before, so I'm not sure why it is not ignoring these files ....

*.py[cod] *.sqlite # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 __pycache__ # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject *.log *.pot *.pyc local_settings.py 
+4
source share
3 answers

If the file already exists, you need to force delete it:

 git rm --cached foo.pyc 

for each file already tracked. Commit, push and profit. The file will remain ignored, but in the working directory.

+9
source

If you want git to ignore changes to the file in the repo, you can use:

 git update-index --assume-unchanged foo.pyc 

This will save the file in the working directory, as well as in the repository itself.

Note that using git rm --cached foo.pyc will store the file in the working directory, but will download the file that will be deleted from the repo.

+1
source

try deleting these files from git cache

 git rm --cached data.sqlite git rm --cached members/model.pyc 
0
source

Source: https://habr.com/ru/post/1501905/


All Articles