Skip to content

Instantly share code, notes, and snippets.

@jennings
Created May 22, 2013 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennings/5624621 to your computer and use it in GitHub Desktop.
Save jennings/5624621 to your computer and use it in GitHub Desktop.
Lists all objects in a Git database and lists them in descending order of size.
# From: http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history/
git rev-list --objects --all | sort -k 2 > allfileshas.txt
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 > bigobjects.txt
for SHA in `cut -f 1 -d\ < bigobjects.txt`; do
echo $(grep $SHA bigobjects.txt) $(grep $SHA allfileshas.txt) | awk '{one=$1; three=$3;$1=$2=$3=$4=$5=$6=""; print one,three,$0}' >> bigtosmall.txt
done;
# bigtosmall.txt now contains the sizes of all Git objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment