Skip to content

Instantly share code, notes, and snippets.

@drosenstark
Created February 8, 2015 07:26
Show Gist options
  • Save drosenstark/ad88360e01edbed975be to your computer and use it in GitHub Desktop.
Save drosenstark/ad88360e01edbed975be to your computer and use it in GitHub Desktop.
Dan's Git Rbranch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
echo "git-rbranch: Creating local branch $1"
git checkout -b $1 # make the branch locally
echo "git-rbranch: Pushing $1 to the server"
git push origin $1 #push it to the server
echo "git-rbranch: Checking out $CURRENT_BRANCH again"
git checkout $CURRENT_BRANCH # switch to $1
echo "git-rbranch: Setting origin/$1 as the tracking branch"
git branch -f $1 origin/$1 # branch to $1, using origin/$1 as the tracking branch
echo "git-rbranch: Checking out $1 with the right origin"
git checkout $1 # checkout the $1 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment