-1

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

enter image description here

torek
  • 389,216
  • 48
  • 524
  • 664
NM Naufaldo
  • 831
  • 5
  • 16
  • 2
    Since 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
  • 1
    Or 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 Answers1

2

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
  • 365
  • 1
  • 8