Skip to content

Instantly share code, notes, and snippets.

@lanefu
Created May 21, 2020 01:25
Show Gist options
  • Save lanefu/46933e635dbafe74372c43b8fce07cf7 to your computer and use it in GitHub Desktop.
Save lanefu/46933e635dbafe74372c43b8fce07cf7 to your computer and use it in GitHub Desktop.
Checkout pull request from GitHub repo.
#!/bin/bash
#ex: /usr/local/bin/checkoutGitHubPR.sh 1234
REMOTE_REPO=origin ## name of your git remote.. typically origin or upstream
MERGE_STATE=merge ## set to "merge" to checkout PR merged against repo, or set to "head" to checkout PR unmerged
PR=${1} ## github pull request number
git fetch -v ${REMOTE_REPO} +refs/pull/${PR}*:refs/remotes/${REMOTE_REPO}/pull/${PR}*
git checkout -f ${REMOTE_REPO}/pull/${PR}/${MERGE_STATE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment