Removing Tracked Files After Adding A Rule to .gitignore

As I learn some of the workings of git in the normal flow of daily use, I struggled for a few minutes this afternoon trying to scrub a directory of DLLs that had been committed to a repo.  These files were previously tracked, so even though the rule was correct, git wasn’t dropping tracking to the files.

Here’s the fix from the mouth of the horse:


If you create a file in your repo named .gitignore git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename

There ya be.  So, create your rule, rm the files and then do your git status to see the changes.  The removing them from tracking is also a change that will have to be committed.