A co-worker and I needed to remove all instances of a binary blob from one of our git repos a while back. This was a lot harder than I thought it should have been, in my opinion. However, distributed version control is not really designed to easily allow folks to delete every instance of a file. But, if you ever run into a case where you do need to expunge a file in git here is how we did it.
Get a new clone of the repo (in scratch/temp space)
git clone REPO_LOCATION
Detach it from the remote origin
git remote rm origin
Remove the file and rewrite history
git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILENAME' HEAD
Remove garbage and lingering files
git reflog expire --expire=now --all && git gc --prune=now --aggressive
Replace the centralized repo (aka REPO LOCATION) and any copies others might be using. Everyone should re-clone the newly replaced repo.
DevOps'ish is on hiatus and is not taking new subscribers at this time. Stay tuned to Chris Short's web site for details on future projects and when DevOps'ish will relaunch.Thank you to all subscribers for your years of support.
There are several guides and HOWTOs that we stumbled across to do this; those might work better for your use case (Google is your friend). But, this five step process worked very well for us.