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 <repo_dir>
cd <repo_dir>
git remote add origin <repo_url>
# 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.
You can do the following:
git clone --depth 1 git@github.com:User/Project.git .
git fetch --unshallow
The first clone
will still be atomic, so if your connection is not reliable enough to fetch the current HEAD then you will have trouble.
The subsequent fetch
should be incremental and retryable if the connection drops half-way though.
The repository is accessible via the http
protocol (aka dumb protocol) here: http://anongit.freedesktop.org/git/libreoffice/core.git.
You can download everything here with wget
or another download manager, and you'll have a clone of the repository. After that, you rename the directory from core.git
to .git
, and use the following command to tell git about the remote url:
$ git remote add remote http://anongit.freedesktop.org/git/libreoffice/core.git
$ git reset --hard HEAD
Increase buffer size so that git can utilize your bandwidth properly. Use following commands.
git config --global core.compression 0
git config --global http.postBuffer 1048576000
git config --global http.maxRequestBuffer 100M
git clone <repo url>
Wait till clone get complete.
do 'git clone --depth 100' It should grab the last 100 commits
I used a my web hosting server with shell access to clone it first and then used rsync to copy it locally. rsync would copy only remaining files when resumed.