Skip to content

Instantly share code, notes, and snippets.

@spraints
Created September 20, 2019 19:57
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 spraints/8bf5a74b48faaa2d5a57d57173418080 to your computer and use it in GitHub Desktop.
Save spraints/8bf5a74b48faaa2d5a57d57173418080 to your computer and use it in GitHub Desktop.
track down large files in your repo's history

First, get a list of all objects with their sizes.

git rev-list --all --objects | awk '{print $1}' | git cat-file --batch-check > obj-sizes.txt

Show the largest object size.

cat obj-sizes.txt | awk '{print $3}' | sort -n | tail -1

Print out just the objects above a certain size. (I'm not happy that this requires a rev-list per object.)

cat obj-sizes.txt | while read obj type size; do
  if [ $size -gt 1000000 ]; then
    echo $size $obj $type $(git rev-list --all --objects | grep $obj);
  fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment