Created
August 8, 2019 09:09
-
-
Save minwoox/f575e7511e200d48929971b8f8817933 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ \cat ~/.local/bin/git-checkout-pr | |
#!/bin/bash -e | |
if [[ $# -ne 1 ]] || [[ ! "$1" =~ (^[1-9][0-9]*$) ]]; then | |
echo "Usage: $0 <pull request ID>" 1>&2 | |
exit 1 | |
fi | |
ORIGIN='origin' | |
if git remote | grep -qE '^upstream$'; then | |
ORIGIN='upstream' | |
fi | |
PR_ID="$1" | |
PR_BRANCH="pr-$PR_ID.$(date '+%Y%m%d%H%M%S')" | |
echo "Checking out the pull request $PR_ID from $ORIGIN .." | |
git fetch "$ORIGIN" "pull/$PR_ID/head:$PR_BRANCH" | |
git checkout "$PR_BRANCH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment