[英]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. 我遇到了data.sqlite和members / model.pyc的问题这就是我的.gitignore文件的外观。 If the above-mentioned files show as modified it means git is still tracking them right?
如果上述文件显示为已修改,则表示git仍在跟踪它们吗? 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忽略对repo中文件的更改,您可以使用:
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. 请注意,使用
git rm --cached foo.pyc
会将文件保留在工作目录中,但会将文件从repo中删除。
try remove those files from git cache 尝试从git缓存中删除这些文件
git rm --cached data.sqlite
git rm --cached members/model.pyc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.