Created
May 20, 2016 15:31
-
-
Save paulmolluzzo/9f0c9f0218c6aaff7ab731a0ccddac9c 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
#!/bin/bash | |
# checkout a pull request by ID into a new branch like: gcopr 123 new-branch-name | |
gcopr() { | |
numRegex='^[0-9]+$' | |
if ! [[ $1 =~ $numRegex ]]; then | |
echo "No ID for PR given" | |
else | |
branchname=${2-pr-$1} | |
git fetch origin pull/$1/head:$branchname | |
git checkout $branchname | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment