简体   繁体   English

.git 本地仓库与使用增量包从第一个仓库复制的其他本地仓库之间的大小差异

[英].git size difference between local repo and other local repo copied from first repo using incremental bundles

I'd like to sync a local repo which.git is in ~/ to google drive.我想将 ~/ 中的.git 中的本地存储库同步到谷歌驱动器。 I've been adviced to forget about copying directly files to google drive and to use bundles.有人建议我忘记将文件直接复制到谷歌驱动器并使用捆绑包。 On the local repo meant to be synced, I've done several commits, without any branch created.在要同步的本地 repo 上,我已经完成了几次提交,但没有创建任何分支。 Afterwards, I've tagged every commit, tags names ranging from t0 to t25.之后,我标记了每个提交,标记名称范围从 t0 到 t25。 The local repo.git size is 2.6G.本地 repo.git 大小为 2.6G。 Then I create the different bundle files using bash: Bundle0 is the bundle obtained with HEAD pointing at the first commit tagged t0, Bundle1 is the incremental bundle corresponding just to the second commit tagged t1, Bundle2 is the incremental bundle corresponding to what whas committed at commit tagged t2 and so on, thus Bundle(i) is the incremental bundle corresponding to commit tagged ti然后我使用 bash 创建不同的包文件:Bundle0 是 HEAD 获得的包,指向标记为 t0 的第一个提交,Bundle1 是对应于标记为 t1 的第二个提交的增量包,Bundle2 是对应于什么提交的增量包commit tagged t2 依此类推,因此 Bundle(i) 是对应于 commit tagged ti 的增量包

cd ~
git switch --detach t0
git bundle create bundle0 HEAD
i=0;while [[ i -le 24 ]];do
let j=i+1; git switch --detach t$j;
git bundle create bundle$j t$i..HEAD;
let i=j;done

Then I have bundle0...bundle25 I go to the folder where I want to use the bundle files to "clone" ~ git repo:然后我有 bundle0...bundle25 I go 到我想使用捆绑文件“克隆”的文件夹〜git repo:

cd /mnt/d
mkdir tmp/
cd tmp/
i=0; while [[ i -le 25 ]];do git pull ~/bundle$i; let i=i+1;done

Things work fine, but there's a huge size difference between both.git folder, as /mnt/d/tmp/.git is 968M whereas ~/.git is 2.6G一切正常,但两者之间存在巨大的大小差异。git 文件夹,因为 /mnt/d/tmp/.git 是 968M 而 ~/.ZBA9F11ECC3497D9993B933FDC2BD61E 是 968M。

If I do git log in both ~/ and /mnt/d/tmp folders, I get the same commit sequences.如果我在 ~/ 和 /mnt/d/tmp 文件夹中执行 git 登录,我会得到相同的提交序列。 I tried then to compare both git repos by copying the original as a remote in /mnt/d/tmp and then run git diff:然后我尝试通过将原始文件复制为 /mnt/d/tmp 中的远程文件来比较 git 存储库,然后运行 git 差异:

cd /mnt/d/tmp
git remote add -f b ~/.git
git remote update
git diff master remotes/b/master

Last command doesnt output anything, seems the two repository are identical.最后一个命令没有 output 任何东西,似乎两个存储库是相同的。

Finally as both.git directory have substantially different sizes, I am wondering wether my incremental bundle "cloning" really work or if I miss plenty of files or files revision from the original repo in the bundle copied repo.最后,由于 both.git 目录的大小有很大不同,我想知道我的增量捆绑“克隆”是否真的有效,或者我是否错过了捆绑复制仓库中原始仓库的大量文件或文件修订。

Any idea?任何想法? Thanks for your help !谢谢你的帮助 !

Git repacks for storage efficiency at long-ish intervals, and any history-schlepping creates a single pack of the schlepped history, so clones tend to be smaller than the repo they're cloned from. Git 会以较长的时间间隔重新打包以提高存储效率,并且任何历史记录都会创建单个记录的记录,因此克隆往往小于它们从中克隆的存储库。

The core command to do a default-settings major repack is git repack -ad , you can hunt up the conveniences, git prune , git gc , git maintenance la la. The core command to do a default-settings major repack is git repack -ad , you can hunt up the conveniences, git prune , git gc , git maintenance la la.

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

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