Skip to content

Instantly share code, notes, and snippets.

@paulmolluzzo
Created May 20, 2016 15:31
Show Gist options
  • Save paulmolluzzo/9f0c9f0218c6aaff7ab731a0ccddac9c to your computer and use it in GitHub Desktop.
Save paulmolluzzo/9f0c9f0218c6aaff7ab731a0ccddac9c to your computer and use it in GitHub Desktop.
#!/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