Remove previously tracked file from git repository
Here’s a simple git command that will remove a previously tracked file from a git repository:
git rm --cached <file>
The file will be removed from the head on the next commit.
I run into this issue often when using Tower to manage repositories. There doesn’t seem to be an easy way to remove items I’d forgotten to add to .gitignore.