Skip to content

Instantly share code, notes, and snippets.

@orgads
Last active October 4, 2017 13:15
Show Gist options
  • Select an option

  • Save orgads/75ca0c4396baad7bcf6b94c6e739aa08 to your computer and use it in GitHub Desktop.

Select an option

Save orgads/75ca0c4396baad7bcf6b94c6e739aa08 to your computer and use it in GitHub Desktop.
#!/bin/sh
merge() {
git merge --no-edit --no-verify origin/$1
git mergetool || exit 1
git commit --no-edit --no-verify
}
#git fetch
read commit p1 p2 <<<$(git rev-list --parents HEAD -n1)
[ -z "$p2" ] && exit 0
upstream=$(upstream.rb $p1)
merged=$(upstream.rb $p2)
merge $merged
merge $upstream
new_commit=$(git show -s --format=%B $commit | perl -0pe 's/\n*\Z/\n/' | git commit-tree -p origin/$upstream -p origin/$merged $(git write-tree))
git reset $new_commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment