A clone that takes forever, a .git folder bigger than the project: before I go looking for big files, I want to know how big the repository actually is.
git count-objects -vH
-v gives the full report and -H prints sizes in KiB, MiB and GiB instead of raw numbers:
count: 73
size: 292.00 KiB
in-pack: 15230
packs: 2
size-pack: 148.31 MiB
garbage: 0
count and size are loose objects, ones git hasn’t packed yet. in-pack and size-pack are the compressed packfiles that hold most of the history. size-pack is the number that comes closest to what a full clone downloads.
A lot of loose objects is normal after a busy day and git packs them during its automatic maintenance. If garbage isn’t zero, something odd is lying in the objects folder that git couldn’t use.
This tells you how big, not why. To find the files that make a repository heavy, list blobs by size with git rev-list --objects --all together with git cat-file --batch-check. And keep in mind that a deleted big file still counts here, because it lives on in history until you rewrite it out.
Further reading: git-count-objects documentation