Skip to content

Instantly share code, notes, and snippets.

@fhightower
Last active June 15, 2017 04:27
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 fhightower/f0c97f0ee7c1bdf7db992173515272a8 to your computer and use it in GitHub Desktop.
Save fhightower/f0c97f0ee7c1bdf7db992173515272a8 to your computer and use it in GitHub Desktop.
Clone github fork and set upstream
function gfork() {
# Clone a repo that is a fork ($1) and set an upstream repo ($2)
# clone the given repo
git clone $1;
# get the name of the cloned repo
REPO=$(echo $1 | grep -o "[^/]*\.git$")
# go into the directory of the cloned repo
cd ${REPO:0:(${#REPO} - 4)}
# set upstream
git remote add upstream https://github.com/$2.git
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment