Last active
April 13, 2024 07:16
-
-
Save davidliyutong/a37a07c7ad2115184e33c80801c0d66d to your computer and use it in GitHub Desktop.
Accelerate github clone by using mirror
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clone github repo | |
# Usage: | |
# | |
# $ chmod +x ./github-fast-clone.sh | |
# $ ./github-fast-clone <user/repo> | |
#!/bin/bash | |
MIRROR=https://hub.fastgit.org/ | |
GIT_HTTP_CONNECT_TIMEOUT=60 | |
DEPTH=3 | |
set +e | |
if [ $# -ge 1 ]; then | |
git clone https://github.com/$1 --depth $DEPTH | |
if [[ $? -ne $(expr 0) ]]; then | |
# In case of bad internet connection, use mirror | |
echo "Connection failed, using mirror" | |
git clone https://hub.fastgit.org/$1 --depth $DEPTH | |
fi | |
else | |
echo "Usage: ./git-fast-clone <user/repo>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment