git gc
already does a git repack
so there is no sense in manually repacking unless you are going to be passing some special options to it.
The first step is to see whether the majority of space is (as would normally be the case) your object database.
git count-objects -v
This should give a report of how many unpacked objects there are in your repository, how much space they take up, how many pack files you have and how much space they take up.
Ideally, after a repack, you would have no unpacked objects and one pack file but it's perfectly normal to have some objects which aren't directly reference by current branches still present and unpacked.
If you have a single large pack and you want to know what is taking up the space then you can list the objects which make up the pack along with how they are stored.
git verify-pack -v .git/objects/pack/pack-*.idx
Note that verify-pack
takes an index file and not the pack file itself. This give a report of every object in the pack, its true size and its packed size as well as information about whether it's been 'deltified' and if so the origin of delta chain.
To see if there are any unusally large objects in your repository you can sort the output numerically on the third of fourth columns (e.g. | sort -k3n
).
From this output you will be able to see the contents of any object using the git show
command, although it is not possible to see exactly where in the commit history of the repository the object is referenced. If you need to do this, try something from this question.