best guide i’ve found to delete a file from git history

Remove a file permanently from git

You use filter-branch to replay the whole history with a filter applied (—filter-tree ‘rm -f file_to_immolate’). Then you remove the original refspec saved by filter-branch (rm -rf ./git/refs/original). Then you run garbage colleciton to remove the objects that are no longer referenced. (git gc)

And suddenly you’re clean.

Also useful if you’ve been mucking about: Repack/Unpack/Prune/etc…



Me on a beautiful early spring day in Napa, in a field of mustard.

Steven Lybeck


  • ph: 415.830.3274

  • View Steven Lybeck's profile on LinkedIn
  • My status