Skip to content

Instantly share code, notes, and snippets.

@superboum
Last active August 3, 2016 17:15
Show Gist options
  • Save superboum/90e3be176086102576367cd08e0ac7c4 to your computer and use it in GitHub Desktop.
Save superboum/90e3be176086102576367cd08e0ac7c4 to your computer and use it in GitHub Desktop.
Git helpers
# Based on:
# http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big
git rev-list --all --objects | \
sed -n $(git rev-list --objects --all | \
cut -f1 -d' ' | \
git cat-file --batch-check | \
grep blob | \
sort -n -k 3 | \
tail -n200 | \
while read hash type size; do
echo -n "-e s/$hash/$size/p ";
done) | \
sort -n -k1 | \
while read size name; do
echo "$(numfmt $size --to=iec-i --suffix=o) $name"
done
git lfs ls-files | \
while read commit star path
do
size=`ls -l $path 2> /dev/null |cut -d " " -f5 2> /dev/null`
echo "$size $path"
done | \
sort -n -k1 | \
while read size name; do
echo "$(numfmt $size --to=iec-i --suffix=o 2> /dev/null) $name"
done
# Usage: ./git-fatfiles.sh | ./sort-by-extension.sh
sed -r 's/^.*\.([a-zA-Z0-9]+)$/\1/' | sort | uniq -c | sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment