How to clone a large git repository

Recently, I needed to clone the ndk while downloading andorid 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 --depth=1

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

$ vim

copy, paste below code into & save.


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

Now, run the script as,

$ ./

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

1 thought on “How to clone a large git repository”

Leave a Comment