/ git-large-files
git-large-files
 1  #!/bin/bash
 2  #set -x 
 3  
 4  # Shows you the largest objects in your repo's pack file.
 5  # Written for osx.
 6  #
 7  # @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
 8  # @author Antony Stubbs
 9  
10  # set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
11  IFS=$'\n';
12  
13  # list all objects including their size, sort by size, take top 10
14  objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head -n 40`
15  
16  echo "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file."
17  
18  output="size,pack,SHA,location"
19  for y in $objects
20  do
21  	# extract the size in bytes
22  	size=$((`echo $y | cut -f 5 -d ' '`/1024))
23  	# extract the compressed size in bytes
24  	compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
25  	# extract the SHA
26  	sha=`echo $y | cut -f 1 -d ' '`
27  	# find the objects location in the repository tree
28  	other=`git rev-list --all --objects | grep $sha`
29  	#lineBreak=`echo -e "\n"`
30  	output="${output}\n${size},${compressedSize},${other}"
31  done
32  
33  echo -e $output | column -t -s ', '