Home » Source Code Management ( SCM ) » Git » How to clone a large Git repository ?

How to clone a large Git repository ?

Recently, I needed to clone the ndk while downloading Android source, ndk size to clone was more than 4GB and my internet speed 512KB, which could take around 20 hours to clone. And, as you know if for any reason, Internet disconnects before git clone is 100%, the entire git needed to be clone from beginning. So, since my Internet was unstable and also with very slow speed, following is the method, I used to clone the git repository, which is bigger and in multiples of GB.

$ git clone https://android.googlesource.com/platform/prebuilts/ndk --depth=1

one the above command clones, current source code, you can download all the history using below shell script,

$ vim fetch.sh

copy, paste below code into fetch.sh & save.

#!/bin/bash

cd ndk
for i in `seq 1 100000`
do
git fetch --depth=$i
echo "fetching iteration / depth $i"
done

Now, run the script as,

$ ./fetch.sh

and wait the code to download rest of the branches & git history.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

1 thought on “How to clone a large Git repository ?”

Leave a Comment