.gitignore 不匹配子目录

.gitignore not matching subdirectories

我有这样的目录树:

__pycache__
systems
    __pycache__
    ...
components
    __pycache__
    ...
...

我尝试了以下 .gitignore 来忽略所有 __pycache__ 目录。但是,它们不起作用 - 只有第一个被忽略。

**/__pycache__/__pycache__/

如何忽略所有这些?

Because I am on Windows, do I have to use a backslash instead

否:

__pycache__/

足以忽略 所有 _pycache__/ 个文件夹。
确保您的 .gitignore 位于存储库的根文件夹中。

检查 git check-ignore -v -- components/_pycache__/aFile 是否有空输出。
为了确定,请尝试 git rm --cached -r components/_pycache__/,然后再次检查。