【发布时间】:2020-04-16 11:07:32
【问题描述】:
我的 .gitignore 文件包含
project/app/__pycache__
但是当我运行 git status 时,它会报告此目录中文件的更改...
mydomain:main satishp$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: project/app/__pycache__/__init__.cpython-37.pyc
deleted: project/app/__pycache__/models.cpython-37.pyc
在 .gitignore 中包含这个目录不应该防止这种情况吗?还是我做错了什么?
【问题讨论】:
-
如果在添加要忽略的路径之前跟踪它,则需要显式取消跟踪文件夹。
-
旁注:Git 从不跟踪 目录,只跟踪单个文件。
git status命令有时会通过列出目录名称来汇总未跟踪的文件,以避免必须列出所有文件的名称,但跟踪或未跟踪是逐个文件的。 -
忽略模式,相比之下,确实可以忽略整个目录。交互是……棘手的。