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

READ  How to create process in Linux using fork system call ?

Leave a Reply

Your email address will not be published. Required fields are marked *