Skip to content

Instantly share code, notes, and snippets.

@alerque
Created March 24, 2014 14:23
Show Gist options
  • Save alerque/9741030 to your computer and use it in GitHub Desktop.
Save alerque/9741030 to your computer and use it in GitHub Desktop.
Quick shell script to list the actual size on disk of what git has stored for each commit in a repo.
#!/bin/zsh
git rev-list --all|
while read sha; do
let total=0
git diff-tree -r -c -M -C --no-commit-id $sha |
cut -d' ' -f3 |
while read blob; do
case $blob in
0000000000000000000000000000000000000000)
continue
;;
*)
let total+=$(git cat-file -s $blob)
;;
esac
done
echo "${sha[0,7]} $total"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment