Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Created September 6, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonioribeiro/e89362f9ed7c7f0a2f93e32bbb392cbb to your computer and use it in GitHub Desktop.
Save antonioribeiro/e89362f9ed7c7f0a2f93e32bbb392cbb to your computer and use it in GitHub Desktop.
function clone () {
REPOSITORY=git@github.com:$1.git
echo "Cloning $REPOSITORY using SSH..."
git clone $REPOSITORY $2 2>/dev/null
if [[ $? -ne 0 ]]
then
REPOSITORY=https://github.com/$1.git
echo 'Falling back to HTTPS ($REPOSITORY)...'
git clone $REPOSITORY $2
if [[ $? -ne 0 ]]
then
echo "Unable to clone $1"
exit 1
fi
fi
echo "Cloned successfully."
}
## Usage:
clone owner/repo <dir-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment