David Callanan
David Callanan

Reputation: 5800

.gitignore not matching subdirectories

I have directory tree like this:

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

I tried the following .gitignores to ignore all __pycache__ directories. However, they are not working - only the first one is ignored.

**/__pycache__/ and __pycache__/

How do I ignore all of them?

Upvotes: 4

Views: 1959

Answers (1)

VonC
VonC

Reputation: 1328712

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

No, you do not need to use a backslash. This is enough to ignore all _pycache__/ folders:

__pycache__/

Make sure your .gitignore is at the root folder of your repository.

Check that this has an empty output:
git check-ignore -v -- components/_pycache__/aFile

To be sure, try this and then check again:
git rm --cached -r components/_pycache__/

Upvotes: 4

Related Questions