Skip to content

Instantly share code, notes, and snippets.

@svenvarkel
Created December 4, 2013 08:44
Show Gist options
  • Save svenvarkel/7784293 to your computer and use it in GitHub Desktop.
Save svenvarkel/7784293 to your computer and use it in GitHub Desktop.
This script finds the n largest files from your git repository.
#!/bin/sh
#
# Credits go to: http://article.gmane.org/gmane.comp.version-control.git/123050
#
usage() {
echo "usage: `basename $0` [<limit>]"
exit 1
}
limit=10
if test $# -gt 1
then
usage
elif test $# -eq 1
then
limit=$1
fi
git rev-list --all --objects |
sed -n $(git rev-list --objects --all |
cut -f1 -d' ' | git cat-file --batch-check | grep blob |
sort -n -k3 | tail -n$limit | while read hash type size;
do
echo -n "-e s/$hash/$size/p ";
done) |
sort -n -k1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment