Frequently asked questions around Git and Version Control.
How can I ignore files that have already been committed to the repo?
Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a .gitignore file with all the file patterns you want to ignore.
However, of course, not everything goes perfect... and files slip through that you later would like to see ignored.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
In three steps, you can clean up your repository and make sure your ignored items are indeed ignored:
# Remove the files from the index (not the actual files in the working copy)
$ git rm -r --cached .
# Add these removals to the Staging Area...
$ git add .
# ...and commit them!
$ git commit -m "Clean up ignored files"
Ignoring Committed Files in Tower
In case you are using the Tower Git client, the app does the heavy lifting for you: when trying to ignore a file that is already tracked in Git, Tower will ask if you want to untrack it - so that the ignore rules can do their work.