git: purging the lurking big file

I was just working with an old repository where I had inadvertently committed a large file ~300MB.  I subsequently removed it, but not in a way that took it out of history.  I discovered it when I went to push to GitHub and it complained.  These are the steps I used to get rid of the file:

  • git filter-branch --prune-empty -f --index-filter 'git rm -rf --cached --ignore-unmatch source/spikes/mo_offender_fak930.txt'
    -tag-name-filter cat -- --all
  • git update-ref -d refs/original/refs/heads/master
  • git reflog expire --expire=now –all
  • git gc --prune=now

Here are some pages I found useful to figure this all out: