I recently checked one of my git repositories at work, which had more than 10,000 branches and more than 30000 tags. The total size of the repo, after a fresh clone is 12Gigs. I am sure there is no reason to have 10000 branches. So I believe they would occupy considerable amount of space in the disks. So, my questions are as follows
All git references (branches, tags, notes, stashes, etc) use the same system. These are:
Reflogs are stored in .git/logs/refs/
based on the reference-name, with one exception: reflogs for HEAD
are stored in .git/logs/HEAD
rather than .git/logs/refs/HEAD
.
References come either "loose" or "packed". Packed refs are in .git/packed-refs
, which is a flat file of (SHA-1, refname) pairs for simple refs, plus extra information for annotated tags. "Loose" refs are in .git/refs/name
. These files contain either a raw SHA-1 (probably the most common), or the literal string ref:
followed by the name of another reference for symbolic refs (usually only for HEAD
but you can make others). Symbolic refs are not packed (or at least, I can't seem to make that happen :-) ).
Packing tags and "idle" branch heads (those that are not being updated actively) saves space and time. You can use git pack-refs
to do this. However, git gc
invokes git pack-refs
for you, so generally you don't need to do this yourself.