Removing GIT History

Completely remove a file from a repository's commit history

I was training a colleague on using git last week with my Powershell script repository. When I reviewed the git history, I realized that there were lots of entries that were no longer necessary: primarily scripts that I deleted because they were obsolete, or never moved past development. I wanted to find a way to purge all entries related to these files from the git repository.

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FILEPATH" HEAD

This took about a dozen minutes to walk through my approx. 400 commits. Each commit has to be checked, and then removed if it referenced the file.

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy