Created
February 19, 2015 11:35
-
-
Save fpersson/4adc71a2b8f70dcddca8 to your computer and use it in GitHub Desktop.
Find large files in git repo
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 | |
TMPFILE="/tmp/gitstat.txt" | |
FILENAME="/tmp/gitstat_files.txt" | |
if [ -d $1 ] ; then | |
if [ -f $2 ] ; then | |
rm $2 | |
fi | |
cd $1 | |
git rev-list --objects --all | sort -k 2 > $FILENAME | |
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 > $TMPFILE | |
for SHA in `cut -f 1 -d\ < $TMPFILE`; do | |
echo $(grep $SHA $TMPFILE) $(grep $SHA $FILENAME) | awk '{print $1,$3,$7}' >> $2 | |
done; | |
head -n 10 $2 | |
else | |
echo "usage: gitstat.sh /path/to/repo /path/to/result.txt" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment