Skip to content

Instantly share code, notes, and snippets.

@avandrevitor
Forked from nmussat/find.repo.biggest.files
Created April 30, 2018 12:42
Show Gist options
  • Save avandrevitor/c4a0f6d88a21b769f4d472c07e09b6d0 to your computer and use it in GitHub Desktop.
Save avandrevitor/c4a0f6d88a21b769f4d472c07e09b6d0 to your computer and use it in GitHub Desktop.
Find biggest files from a Git repository
#!/bin/bash
# Find biggest files from a Git repository
# See http://progit.org/book/ch9-7.html
MAX_FILES=20
LINES=`git verify-pack -v .git/objects/pack/pack-*.idx | grep blob | sort -k 3 -n | tail -${MAX_FILES}`
IFS=$'\n'
for LINE in $LINES
do
SHA=`echo $LINE | awk '{print $1}'`
SIZE=`echo $LINE | awk '{print $3}'`
FILE=`git rev-list --objects --all | grep $SHA | awk '{print $2}'`
printf '%.8s... %-10d %s\n' $SHA $SIZE $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment