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 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 git@github.com: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 git@github.com: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