#!/bin/bash
#set -x 

# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs

# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
IFS=$'\n';

# list all objects including their size, sort by size, take top 10
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head -n 25`

echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."

output="size,pack,SHA,location"
for y in $objects
do
	# extract the size in bytes
	size=$((`echo $y | cut -f 5 -d ' '`/1024))
	# extract the compressed size in bytes
	compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
	# extract the SHA
	sha=`echo $y | cut -f 1 -d ' '`
	# find the objects location in the repository tree
	other=`git rev-list --all --objects | grep $sha`
	#lineBreak=`echo -e "\n"`
	output="${output}\n${size},${compressedSize},${other}"
done

echo -e $output | column -t -s ', '
Add a helper script to delete big files from git
Add a helper script to delete big files from git


Former-commit-id: b39091f421154db612b7b73007cb30b18cf45dd4 [formerly 22ffb8e52cc4a9fd38a0ac216fb1eaf83c84b035] [formerly ca848b4af3ae7cda6065b14b5437d35b40bcacd9 [formerly 9a5694b80378bc9b3dcc3764e8434d66b69b06fc]]
Former-commit-id: 98fecccb7eb7858fd247950e4f3853b08c2a443c [formerly 02af2941d6d47c0fa77a31797b5eaf0d8124735a]
Former-commit-id: c981404c18e3fd138c18978e4665b55aaeff411e