简体   繁体   English

为什么裸git repo的大小是非裸仓库的1/4?

[英]Why is a bare git repo 1/4 the size of a non-bare?

I've cloned a local repo into two different repos: one bare and one non-bare. 我已将本地存储库克隆为两个不同的存储库:一个裸存储库和一个非裸存储库。 The bare one is 750 MB and the non-bare is 3 GB. 裸机为750 MB,非裸机为3 GB。 Since I can "convert" freely between the two, the same information must be in both the bare and non-bare repositories. 由于我可以在两者之间自由地“转换”,因此相同的信息必须同时存在于裸仓库和非裸仓库中。 Then how can the non-bare one be four times as large? 那么,非裸露的光环怎么能变成四倍呢?

I'd understand if it were twice as large, since maybe every file needs to reside both in .git and in the working directory. 我想知道它是否是它的两倍大,因为也许每个文件都需要驻留在.git和工作目录中。 But why four times? 但是为什么要四次呢?

Because indexes are "packed", compressed. 因为索引是“打包”的,所以被压缩。 Their size is smaller than the size of the versioned files, especially if they are text files. 它们的大小小于版本文件的大小,尤其是文本文件时。

Files stored in .git/objects are often packed. 存储在.git/objects中的文件通常被打包。 That means they are compressed and not aligned to block boundaries. 这意味着它们被压缩且未对齐块边界。 Rather the checkout likely contains very many small files. 相反,结帐可能包含很多小文件。 I'd not be surprised if the ratio is better when using a filesystem with better packing of small files such as btrfs. 如果使用更好地打包小文件(例如btrfs)的文件系统时该比率更好,我不会感到惊讶。 So both aspects playing together yield in your .git/objects directory being relatively small. 因此,在您的.git/objects目录中,这两个方面的共同作用相对较小。 That is if you didn't forget to git gc . 也就是说,如果您没有忘记git gc ;-) ;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM