Skip to content

Instantly share code, notes, and snippets.

@DekusDenial
Created October 3, 2013 03:37
Show Gist options
  • Save DekusDenial/6804524 to your computer and use it in GitHub Desktop.
Save DekusDenial/6804524 to your computer and use it in GitHub Desktop.
First, clone your forked repo. Second, set remote upstream to be the repo your repo forking from. Last, rebase the current HEAD with the remote HEAD
#!/usr/bin/env sh
repo=$( echo $1 | sed -E 's/^.*\///' | sed -E 's/\.git//' )
echo "\n<<<<<<<<< Cloning [${repo}] from [${1}] >>>>>>>>>"
T1=$(date +%s)
git clone $1 && cd $repo
HEAD=$( git rev-parse --abbrev-ref HEAD )
echo "\n<<<<<<<<< Adding [${2}] as upstream remote >>>>>>>>>"
git remote add upstream $2
echo "\n<<<<<<<<< Rebase [${HEAD}] from remote upstream >>>>>>>>>"
git fetch upstream && git checkout ${HEAD}
git rebase upstream/${HEAD}
T2=$(date +%s)
echo "\n<<<<<<<<<< Took $(($T2 - $T1))s >>>>>>>>>>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment