简体   繁体   English

为什么git仍然跟踪已经添加到.gitignore文件的扩展名的文件

[英]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.sqlitemembers / 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.

相关问题 Git不会忽略我的.gitignore文件中的某些文件扩展名。 为什么? - Git not ignoring some files extensions in my .gitignore file. Why? git 显示已添加到 gitignore 的文件中的更改? - git is showing changes in files that are already added to gitignore? 为什么git仍然指向.gitignore文件 - Why is git still pointing to .gitignore files Git 仍然跟踪 gitignore 文件中的文件 - Git still tracks files in gitignore file git diff在.gitignore中但已添加以进行跟踪的文件上 - git diff on a file that is in .gitignore but has been added for tracking Git 仍在跟踪我已经删除的文件 - Git still tracking a file that I already deleted 即使我尝试忽略.gitignore仍会跟踪文件,为什么? - .gitignore still tracking files even if I tried to ignore them, why? 删除所有已经基于.gitignore添加到git仓库的文件 - Delete all files already added to git repository based on .gitignore Git:无论如何,是否要推送一个已经添加到gitignore中的文件? - Git: Is there anyway to push one file which is already added into gitignore? npm-debug.log位于.gitignore文件中,但我仍然收到消息“没有添加任何内容来提交但存在未跟踪的文件(使用” git add”进行跟踪)” - npm-debug.log is in .gitignore file, but I still get the messsage “nothing added to commit but untracked files present (use ”git add“ to track)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM