为什么这个git浅克隆比我预期的更大? [英] Why is this git shallow clone bigger than I expected?

查看:191
本文介绍了为什么这个git浅克隆比我预期的更大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大约24MB的回购,但项目中的文件实际上只有2MB左右。我的印象是,带有--depth 1的浅克隆会使我接近实际文件的2MB(无整个回购)。



当我做浅克隆时,新的回购仅显示当前分支,但大小相同(24MB),并使用gitx查看回购,我可以看到整个历史回到最初的提交。



我想要一种方法来获取文件的当前状态(用于上传到服务器),而不需要所有的历史记录。我做错了什么或者误解了浅层克隆的目的?

可能会通过将新存储库中的对象硬链接到旧存储库中的对象(它将其作为本地文件系统的优化)来操作。要查看是否属于这种情况,可以禁用硬链接:

  git clone --depth 1 --no-hardlinks / path / to / repo.git 

如果您只是想让文件的当前状态为上传到服务器,您应该使用 git archive 来生成树的ZIP或tar档案。


I have a repo that is about 24MB in size but the files in the project are actually just around 2MB. I was under the impression that a shallow clone with --depth 1 would pretty much get me down close to the 2MB of the actual files (sans entire repo).

When I do the shallow clone the new repo shows only the current branch but the size is identical (24MB) and looking at the repo with gitx I can see the entire history back to the initial commit.

I'd like a way to get just the current state of files (for uploading to a server) without all the history. Am I doing something wrong or just misunderstanding the purpose of the shallow clone?

解决方案

If this is a local clone, then the clone may be operating by hard linking objects in your new repository to those in your old repository (it does this as an optimization on local file systems). To see if this is the case, you can disable hard linking:

git clone --depth 1 --no-hardlinks /path/to/repo.git

If you're just trying to get the current state of files to upload to a server, you should use git archive to generate a ZIP or tar archive of your tree.

这篇关于为什么这个git浅克隆比我预期的更大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆