How do I remove *.pyc files are already tracked by Git?

I have .gitignore in my repo but it’s not ignoring .pyc files. After investigation, I noticed that .gitignore only prevents new files from being tracked. If a .pyc file is already in the repository, Git will continue to track it even if it’s now in .gitignore.

Solution

Run the following command to remove tracked .pyc files:
git rm –cached -r ‘*.pyc’

Then commit the changes:
git commit -m “Remove tracked .pyc files”

Problem is resolved!

No Comments

Leave a Reply