Skip to content

Instantly share code, notes, and snippets.

@spraints
Created Sep 20, 2019
Embed
What would you like to do?
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