Updated .gitignore But Files Are Still Tracked?

less than 1 minute read

Git has a simple feature to ignore files and folders.  Create a .gitignore file and using basic glob syntax, you can tell Git what files you do not want tracked in the repository.

But what happens when you've already submitted stuff you no longer want tracked?  You can update the .gitignore file, but Git still holds on to the items you've already submitted.

Let's say you're using ReSharper (you should, it's awesome) and you've accidentally submitted the ReSharper project files into the repo.

You update your .gitignore as follows:
# Ignore ReSharper stuff
_ReSharper*
Easy.  Now, to get Git to release the already tracked stuff, run this:
git rm -r --cached *_ReSharper*
And all the ReSharper associated stuff will now be flagged for removal.  Commit your changes (along with the .gitignore of course) and you're done.

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...