Created
November 6, 2016 11:20
-
-
Save nkmathew/2a131e67d1cd95fcd4ffc1602e4e0f6c to your computer and use it in GitHub Desktop.
Script for cloning repos from GitHub using a username/repo-name combo
This file contains hidden or 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
#!/usr/bin/env bash | |
# Script for cloning repos from GitHub using a username/repo-name combo | |
# | |
# e.g. cloning last 10 commits: | |
# | |
# clone nkmathew/yasi-sexp-indenter 10 | |
# | |
if [[ -n $1 ]]; then | |
if [[ $1 =~ ^http[s]*:// ]]; then | |
url=$1 | |
else | |
url="https://www.github.com/$1" | |
fi | |
echo -e "\033[1;33m\nRepo: $url\033[0m" | |
if [[ -n $2 && $2 =~ ^[0-9]+$ ]]; then | |
git clone $url --depth=$2 $3 $4 $5 | |
else | |
git clone $url | |
fi | |
else | |
echo -e "Usage:\n clone.sh [repo-url] [x-commits]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment