如何有效地从浅克隆中 git fetch [英] How to git fetch efficiently from a shallow clone

查看:51
本文介绍了如何有效地从浅克隆中 git fetch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用git 分发操作系统并使其保持最新.我们无法分发完整的存储库,因为它太大(> 2GB),所以我们一直在使用浅克隆(~300M).然而,最近从浅克隆中获取时,现在获取整个 >2GB 存储库的效率低下.这是部署带宽的一种站不住脚的浪费.

We use git to distribute an operating system and keep it upto date. We can't distribute the full repository since it's too large (>2GB), so we have been using shallow clones (~300M). However recently when fetching from a shallow clone, it's now inefficiently fetches the entire >2GB repository. This is an untenable waste of bandwidth for deployments.

git 文档说你不能从一个浅仓库中获取数据,尽管这完全不是真的.是否有任何解决方法可以使 git clone --depth 1 能够从中获取更改的内容?或者其他一些策略来保持分布大小尽可能小,同时拥有 git 需要进行更新的所有位?

The git documentation says you cannot fetch from a shallow repository, though that's strictly not true. Are there any workarounds to make a git clone --depth 1 able to fetch just what's changed from it? Or some other strategy to keep the distribution size as small as possible whilst having all the bits git needs to do an update?

我曾尝试从 --depth 20 克隆以查看它是否会更有效地升级,但没有成功,但没有成功.我也研究过 http://git-scm.com/docs/git-bundle,但这似乎创建巨大的捆绑包.

I have unsuccessfully tried cloning from --depth 20 to see if it will upgrade more efficiently, that didn't work. I did also look into http://git-scm.com/docs/git-bundle, but that seems to create huge bundles.

推荐答案

--depth 是一个 git fetch 选项.我看到文档并没有真正强调 git clone 进行提取.

--depth is a git fetch option. I see the doc doesn't really highlight that git clone does a fetch.

当你获取时,两个 repos 交换谁拥有什么的信息,从远程的头部开始,向后搜索获取的引用历史中最近的共享提交,然后填充所有丢失的对象以完成新的在最近的共享提交和新获取的提交之间提交.

When you fetch, the two repos swap info on who has what by starting from the remote's heads and searching backward for the most recent shared commit in the fetched refs' histories, then filling in all the missing objects to complete just the new commits between the most recent shared commits and the newly fetched ones.

A --depth=1 fetch 只获取分支提示,没有先前的历史记录.进一步获取这些历史记录将通过上述过程获取所有新内容,但如果先前获取的提交不在新获取的历史记录中,则 fetch 将检索所有这些 - 除非您使用 --depth 限制获取.

A --depth=1 fetch just gets the branch tips and no prior history. Further fetches of those histories will fetch everything new by the above procedure, but if the previously-fetched commits aren't in the newly fetched history, fetch will retrieve all of it -- unless you limit the fetch with --depth.

您的客户从一个 repo 中提取了 depth=1 并将 url 切换到另一个 repo.在这个新的 repo 的 refs 中,至少有一个很长的祖先路径显然与你的 repo 中当前的任何内容都没有共享.这可能值得研究,但无论哪种方式,除非有某些特殊原因,否则您的客户可以只执行每次提取 --depth=1.

Your client did a depth=1 fetch from one repo and switched urls to a different repo. At least one long ancestry path in this new repo's refs apparently shares no commits with anything currently in your repo. That might be worth investigating, but either way unless there's some particular reason, your clients can just do every fetch --depth=1.

这篇关于如何有效地从浅克隆中 git fetch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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