Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make git clone faster with multiple threads?

Tags:

git

git-clone

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.

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

like image 891
simonzack Avatar asked Nov 16 '14 13:11

simonzack


People also ask

How do I clone a git repo faster?

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.

Is git multithreaded?

A few selected operations are multi-threaded if you compile with thread support (i.e., do not set NO_PTHREADS when you build). But object packing (used during fetch/push, and during git-gc ) is multi-threaded (at least the delta compression portion of it is). git may fork to perform certain asynchronous operations.

What does depth 1 do in git clone?

Developers should be aware that the depth 1 clone operation only pulls down one branch. If the remote repository contains other branches, they won't be able to check them out locally without a pathspec error. After a git clone depth 1 operation, attempts to checkout an alternate branch will trigger a pathspec error.

Can you clone a repo multiple times?

Simply clone your project's repo twice (or even more often). When your work on a feature branch is done, simply push that branch and check it out on your 2nd copy to run tests there. You can pick up a new story and work on that on your "main" project directory.


1 Answers

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".

like image 59
VonC Avatar answered Sep 21 '22 13:09

VonC