Skip to main content

Ignoring files you've already committed

If you try to .gitignore files after committing them, you’ll notice it doesn’t work: git still tracks changes to those files and they still appear in your remote repo. What to do?

You need to remove those files from git’s cache.

You can remove specific files or folders:

git rm --cached <file>
git rm -r --cached <folder>

Or just clear the whole cache:

git rm -r --cached .

Then commit your changes so git knows which files it should track going forward:

git add .
git commit -m "fix: stop tracking ignored files"