70 %
Chris Biscardi

Removing a file from all git commits

I recently accidentally committed my .envrc file! Luckily it was just a public key this time, but I almost pushed some private credentials. So I had to remove that file from multiple git commits before I pushed again.

You can remove a file from all git history with filter-branch and git rm

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