我试图在文件中忽略 3 个路径.gitignore:
aws_scripts/python/aws_tools/__pycache__/
.vscode/
aws_scripts/output_files/
aws_scripts/source_files/
Run Code Online (Sandbox Code Playgroud)
除了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")
Run Code Online (Sandbox Code Playgroud)
如果我注释掉 中的行.gitignore,这些目录又会出现在 中git status。
.gitignore注释掉的行:
#aws_scripts/python/aws_tools/__pycache__/
#.vscode/
#aws_scripts/output_files/
#aws_scripts/source_files/
Run Code Online (Sandbox Code Playgroud)
导致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/
Run Code Online (Sandbox Code Playgroud)
为什么只有__pycache__目录不起作用.gitignore?
Rom*_*lka 41
请注意输出modified中的git status。这意味着您已经添加并提交了__pycache__.
git rm -rf <PATH>它,提交,并且应该开始被适当地忽略。
.gitignore从一开始就从官方开始并扩展它们并不是一个坏主意:https: //github.com/github/gitignore