Git Tip: Removing .gitignore’d Files after adding to .gitignore

Very handy trick for removing .gitignore’d files from a repo AFTER those files previously had been included in the repo:

git rm --cached `git ls-files -i --exclude-from=.gitignore`

Now commit the deletion(s):

git commit -m 'Repo pruned - Removed all files that are in the .gitignore'

And if you need to sync with a remote, push it:

git push origin master

And PRESTO – repo is cleaned up without modifying files.

h/t Blundell here