Skip to content

Instantly share code, notes, and snippets.

@cbx
Created July 24, 2014 12:51
Show Gist options
  • Select an option

  • Save cbx/4e6197f88a1c606bc037 to your computer and use it in GitHub Desktop.

Select an option

Save cbx/4e6197f88a1c606bc037 to your computer and use it in GitHub Desktop.
list all git files from big to small
# inspired by http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
function git_bigobjects {
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
}
function git_allfiles {
git rev-list --objects --all | sort -k 2
}
function git_bigtosmall {
git_bigobjects > ~/tmp/git-bigobjects.txt
git_allfiles > ~/tmp/git-allfiles.txt
for SHA in `cut -f 1 -d " " < ~/tmp/git-bigobjects.txt`; do
echo $(grep $SHA ~/tmp/git-bigobjects.txt) $(grep $SHA ~/tmp/git-allfiles.txt) | awk '{print $1,$3,$7}'
done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment