I want to clone LibreOffice. From the official website, this is what\'s written:
All our source code is hosted in git:
Clone:
$ git clone gi
The best method that I know of is to combine shallow clone (--depth 1
) feature with sparse checkout, that is checking out only the subfolders or files that you need. (Shallow cloning also implies --single-branch
, which is also useful.) See udondan's answer for an example.
Additionally, I use a bash loop to keep retrying until finished successfully. Like this:
#!/bin/bash
git init
cd
git remote add origin
# Optional step: sparse checkout
git config core.sparsecheckout true # <-- enable sparse checkout
echo "subdirectory/*" >> .git/info/sparse-checkout # <-- specify files you need
# Keep pulling until successful
until $( git pull --depth=1 origin master ); do # <-- shallow clone
echo "Pulling git repository failed; retrying..."
done
In this way I can eventually pull large repos even with slow VPN in China…
Importantly, by pulling this way you will still be able to push.