Created
November 20, 2015 03:18
-
-
Save nhoag/3f21cc113d92fd5676d4 to your computer and use it in GitHub Desktop.
Return a list of the largest objects in a Git repo in a human-readable format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HASHES_SIZES=$(git verify-pack -v .git/objects/pack/pack-*.idx \ | |
| sort -k 3 -rn \ | |
| head -20 \ | |
| awk '{print $1,$3}' \ | |
| sort) | |
HASHES=$(echo "$HASHES_SIZES" \ | |
| awk '{printf $1"|"}' \ | |
| sed 's/\|$//') | |
HASHES_FILES=$(git rev-list --objects --all \ | |
| \grep -E "($HASHES)" \ | |
| sort) | |
paste <(echo "$HASHES_SIZES") <(echo "$HASHES_FILES") \ | |
| sort -k 2 -rn \ | |
| awk '{ | |
size=$2; $1=""; | |
$2=""; | |
$3=""; | |
split( "KB MB GB" , v ); | |
s=0; | |
while( size>1024 ){ | |
size/=1024; s++ | |
} print int(size) v[s]"\t"$0 | |
}' | |
| column -ts $'\t' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
handy little script. thanks for sharing!