我有三个路径在我的.gitignore
文件中想要忽略:
aws_scripts/python/aws_tools/__pycache__/
.vscode/
aws_scripts/output_files/
aws_scripts/source_files/
除了 aws_scripts/python/aws_tools/__pycache__/
以外,其他都被忽略了。
git status
On branch develop
Your branch is up to date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: aws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
如果我在.gitignore
中注释掉这些行,那么这些目录会再次出现在git status
中。
.gitignore
的已注释行:
#aws_scripts/python/aws_tools/__pycache__/
#.vscode/
#aws_scripts/output_files/
#aws_scripts/source_files/
git status
的结果:
git status
On branch develop
Your branch is up to date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: aws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
.vscode/
aws_scripts/output_files/
aws_scripts/source_files/
为什么只有__pycache__
目录不与.gitignore
一起工作?
未跟踪的文件: (使用“git add <file>…”将其包含在提交中) .gitignore .vscode/ aws_scripts/output_files/ aws_scripts/source_files/
但是当我将它们添加到.gitignore
并执行git status
时,它们就会消失。 - Tim Dunphyaws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc
是一个被追踪的文件,否则 Git 不会将其列为“已修改”。 - tkausl