How to make git clone faster with multiple threads?

霸气de小男生 提交于 2019-12-02 17:57:40
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?".

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

Try git config --global http.postBuffer 524288000.

Ciro Santilli 新疆改造中心法轮功六四事件

git clone --jobs

This might help if you have multiple submodules:

-j <n>, --jobs <n>

The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option.

Added on v2.9.0 (March 2016) at commit 72290d6 :

clone: allow an explicit argument for parallel submodule clones

I wonder if this will help if you have two modules on a single server. TODO benchmark on GitHub.

Definitely should if you have submodules from different servers.

I wonder if Git is smart enough to fetch from different servers as much as possible at a given time instead of possibly putting all jobs on a single server at once randomly.

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!