Skip to content

Instantly share code, notes, and snippets.

@umireon
Created December 1, 2016 07:46
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 umireon/c066a8213c5cfa39ae6bdbe1616c986b to your computer and use it in GitHub Desktop.
Save umireon/c066a8213c5cfa39ae6bdbe1616c986b to your computer and use it in GitHub Desktop.
Extract the user name and repository name on GitHub from `origin`
REPOURL=$(git remote get-url origin | grep '^https://github.com') || {
echo error: origin is not on github
exit 1
}
GITHUB_USER=${REPOURL#https://*/}
GITHUB_USER=${GITHUB_USER%/*}
GITHUB_REPO=${REPOURL#https://*/*/}
GITHUB_REPO=${GITHUB_REPO%.git}
echo $GITHUB_USER $GITHUB_REPO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment