Skip to content

Instantly share code, notes, and snippets.

@gabrielpoca
Created March 3, 2015 17:30
Show Gist options
  • Select an option

  • Save gabrielpoca/e7e9a1e438de215b6d59 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielpoca/e7e9a1e438de215b6d59 to your computer and use it in GitHub Desktop.
#!/bin/sh
current=`git branch | sed -n '\/* /s///p'`
destiny=${1:-master}
# 1. Update destiny
git fetch
git checkout $destiny
[[ $? == 0 ]] || exit "failed to switch to $destiny"
git rebase
# 2. rebase PR branch
git checkout $current
git rebase $destiny
[[ $? == 0 ]] || exit "failed to rebase from $destiny"
git rebase -i $destiny
# 3. merge
git push -f
git checkout $destiny
git merge --ff-only $current
git push
# 4. remove branch
git push origin :$current
git branch -d $current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment