简体   繁体   中英

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. 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. 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. 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. So both aspects playing together yield in your .git/objects directory being relatively small. That is if you didn't forget to git gc . ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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