git

What is taking up so much space in my git repository?

This can be a common task, but I always forget the exact commands and have to go on an internet hunt if its not on the history of the machine I am using.

Two steps:

Find the biggest five blobs
$ git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5
ad293261c761f56e388279ea80806a8f6522fa7d blob   25281 16181 394018
28254a0c9161d63c5375f2cb6b05cd2d7e1954a6 blob   29741 7138 563333
d37caac154fedd0126b83afef8d26cc2c3c11f41 blob   41966 40508 269339
c8df81fb8671a747cd2e308dee0f76c678bc3ffa blob   137496 105526 413219
ceb7aaf4723990ba0007a1c018c414a338180a37 blob   187282 161105 108234

In this case, blob ceb7aaf4723990ba0007a1c018c414a338180a37  is the biggest, as it uses 187282/1024=183 KB

What file is this blob?
$ git rev-list --objects --all | grep ceb7aaf4723990ba0007a1c018c414a338180a37
ceb7aaf4723990ba0007a1c018c414a338180a37 resources/ncp-config.jpg

There we have it. Now, if we want to free the space, we can use git forget-blob

Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]

Leave a Reply

Your email address will not be published. Required fields are marked *