Skip to content

Instantly share code, notes, and snippets.

@spalger
Last active January 5, 2016 01:25
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 spalger/d07decea6a155e77cf6d to your computer and use it in GitHub Desktop.
Save spalger/d07decea6a155e77cf6d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# call this with the pr number you want to apply and the base branch of that pr
#
# backport pr 5805, which was submitted against master, to 4.4:
# git co 4.4
# git cherry-pick-pr 5805
#
# backport pr 5840, which was submitted against 4.x, to 4.4:
# git co 4.4
# git cherry-pick-pr 5840 4.x
#
#!/usr/bin/env bash
set -e
num="$1"
baseBranch="${2-master}"
# fetch the latest version of pr $num
git fetch -q upstream pull/$num/head
git cherry-pick -x "$baseBranch..FETCH_HEAD" --allow-empty-message --allow-empty
# after this is complete you can simply push the target branch to upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment