git: purging the lurking big file

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:

http://stackoverflow.com/questions/6017987/is-there-a-way-in-git-to-list-all-deleted-files-in-the-repository

http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository

http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history

Leave a Reply

Your email address will not be published. Required fields are marked *