Search code examples
gitgitignore

Git Ignore All __pycache__ Directory


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


Solution

  • 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.