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