Skip to main content

Ignoring a file git previously tracked

Problem: you added a file to your .gitignore, but changes are still being tracked because you’ve previously tracked that file.

To fix that and properly ignore the file, you need to remove it from git’s cache:

# remove a specific file from git's cache
git rm --cached filename
# or remove everything from the cache cache
git rm -r --cached .
# commit your changes
git add .
git commit -m "stop tracking ignored files"