如何使用多线程使 git clone 更快?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26957237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:40:27  来源:igfitidea点击:

How to make git clone faster with multiple threads?

gitgit-clone

提问by simonzack

My internet speed to github was never fast, and it's lingering at 50kb/s (my internet speed is 20mbit which is not very fast but still much faster than this). The repository is multi-gb by my estimates, so it'll take a very long time.

我到 github 的网速从来都不是很快,一直在 50kb/s 徘徊(我的网速是 20mbit,不是很快,但仍然比这个快得多)。据我估计,存储库是多 GB 的,因此需要很长时间。

Does git support downloading the objects using multiple-threadsso I can max-out my internet speed?

git 是否支持使用多线程下载对象,以便我可以最大限度地提高互联网速度?

回答by VonC

You can at least try and mitigate the issue, with a shallow clone (meaning not cloning the all history):

您至少可以尝试使用浅克隆(意味着不克隆所有历史记录)来缓解问题:

git clone --depth 1 <repository>

Make sure to have a git 1.9+, as I explained in "Is git clone --depth 1(shallow clone) more useful than it makes out?".

确保有一个Git 1.9+,正如我在解释“git clone --depth 1(浅克隆)比它使出来?更有用”。

Note: Git 2.5 (Q2 2015) even supports a single fetch commit!See "Pull a specific commit from a remote git repository".

注意:Git 2.5(2015 年第二季度)甚至支持单次获取提交!请参阅“从远程 git 存储库中提取特定提交”。

回答by WHS

Try git config --global http.postBuffer 524288000.

试试git config --global http.postBuffer 524288000

回答by Thorbj?rn Ravn Andersen

I have seen similar behavior under Windows, where the cause was the Windows anti-virus which was set to be very aggressive and git was transferring a lot of small files. Dual booting to Linux gave full speed for git clones.

我在 Windows 下看到过​​类似的行为,原因是 Windows 防病毒设置非常激进,而 git 正在传输大量小文件。双引导到 Linux 为 git 克隆提供了全速。

If you have the specifications consider creating a test Windows installation (for instance virtually using VirtualBox or vmware player) where you install a virgin Windows from scratch and only add the necessary git software. You can then see if the problem is "inside" or "outside" git. My personal guess is that this will be fast.

如果您有规范,请考虑创建一个测试 Windows 安装(例如虚拟使用 VirtualBox 或 vmware player),您可以在其中从头安装一个原始的 Windows,并且只添加必要的 git 软件。然后,您可以查看问题是在 git 的“内部”还是“外部”。我个人的猜测是这会很快。