Last active
November 18, 2018 04:34
-
-
Save bekicot/548e50b29fb92d6ae8a2b5b8fe1cf792 to your computer and use it in GitHub Desktop.
Clone GitHub Repo to nested directory with `username/repository_name`. Supports both ssh and https.
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 | |
# Usage Example | |
# github-clone [email protected]:rubygems/rubygems.org.git | |
# github-clone https://github.com/rubygems/rubygems.org.git | |
set -e | |
URI=$1 | |
REPO=$(basename $1) | |
REPO="${REPO%.*}" | |
GITHUB_USERNAME=$(basename $(dirname $1)) | |
GITHUB_USERNAME=${GITHUB_USERNAME##*:} | |
# e.g | |
# github-clone [email protected]:rubygems/rubygems.org.git | |
# Will clone the repository to rubygems/rubygems. | |
git clone $URI $GITHUB_USERNAME/$REPO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment