I just follow this solution to add __pycache__/
in my .gitignore
but it doesn't work. All directory with format __pycache__
still appear in my git status
Asked
Active
Viewed 9,948 times
1

torek
- 448,244
- 59
- 642
- 775

NM Naufaldo
- 1,032
- 1
- 12
- 30
-
2Since it says `modified` for those `__pycache__` directories, that means those files are already committed and tracked in your repo, and adding it to gitignore won't "un-commit" them. – Gino Mempin Feb 15 '22 at 09:25
-
1Or the more general: [How can I make Git "forget" about a file that was tracked, but is now in .gitignore?](https://stackoverflow.com/q/1274057/2745495) – Gino Mempin Feb 15 '22 at 09:26
1 Answers
6
As you have already committed the pycache/ folders before, when you add it to gitignore it can't ignore them, they have already been pushed. You, therefore, need to remove them from your repository using git rm -r <path to __pycach__>
and commit this change. Then the gitignore should work.

Joshua Zeltser
- 488
- 2
- 9