Skip to content

Instantly share code, notes, and snippets.

@ke4roh
Last active April 22, 2017 12:11
Show Gist options
  • Save ke4roh/d69315857293e409835e21344e3484b8 to your computer and use it in GitHub Desktop.
Save ke4roh/d69315857293e409835e21344e3484b8 to your computer and use it in GitHub Desktop.
Show large objects in the git repo for cleaning cruft
$ cat git-show-big
#!/bin/bash
# Ref http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
SHAS=$(git rev-list --objects --all | sort -k 2)
BIGOBJS=$(git gc && git verify-pack -v .git/objects/pack/pack-*.idx | egrep "^\w+ blob\W+[0-9]+ [0-9]+ [0-9]+$" | sort -k 3 -n -r)
join <(echo "$BIGOBJS" | sort ) <(echo "$SHAS" | sort ) | sort -k 3 -n -r | cut -f 1,3,6- -d\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment