简体   繁体   中英

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

I am having problems with data.sqlite and members/model.pyc This is how my .gitignore file looks. If the above-mentioned files show as modified it means git is still tracking them right? These files were not tracked before so I am not sure why it is not ignoring those 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

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

git rm --cached foo.pyc

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

If you would like git to ignore changes to a file in the repo you can use:

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

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

Note that using git rm --cached foo.pyc will keep the file in the working directory but will stage the file to be deleted from the repo.

try remove those files from git cache

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM