git分支和标签如何存储在磁盘中? [英] How git branches and tags are stored in disks?
问题描述
我最近检查了一个工作中的git存储库,其中有10,000多个分支和30000多个标签。新鲜克隆后,回购的总大小为12Gigs。我确信没有理由要有10000个分支机构。因此,我相信它们会在磁盘中占据相当大的空间。因此,我的问题如下:
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
- 分支和标签如何存储在磁盘中,例如使用了什么数据结构,存储了哪些信息每个分支?
- 如何获取有关分支的元数据?就像创建该分支的时间一样,分支的大小是多少。
推荐答案
所有git引用(分支,标签,注释,存储等)使用相同的系统。它们是:
All git references (branches, tags, notes, stashes, etc) use the same system. These are:
- 引用本身,以及
- reflogs
基于引用名称,引用存储在 .git / logs / refs /
中,其中一个例外: HEAD
的引用日志存储在 .git / logs / HEAD
中,而不是 .git中/ logs / refs / HEAD
。
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
.
引用来自松散或打包。打包的引用位于 .git / packed-refs
中,这是用于简单引用的(SHA-1,refname)对的平面文件,以及带注释标签的其他信息。 宽松的裁判在 .git / refs / 名称
中。这些文件包含原始SHA-1(可能是最常见的)或文字字符串 ref:
,后跟符号引用的另一个引用的名称(通常仅用于 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 :-) ).
打包标记和 idle分支头(那些那些没有被打包的符号引用(或者至少我似乎无法做到这一点:-))。不会主动更新)节省了空间和时间。您可以使用 git pack -refs
执行此操作。但是, git gc
会为您调用 git pack-refs
,因此通常您不需要自己执行此操作。
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.
这篇关于git分支和标签如何存储在磁盘中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!