Created
August 29, 2018 17:54
-
-
Save TheLandolorien/fac0faf0e80d822634248af9a080f2f8 to your computer and use it in GitHub Desktop.
Pull GitHub PR based on Branch and PR#
This file contains 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 | |
if [[ "$#" -eq 2 ]]; then | |
TARGET_BRANCH="$1" | |
ID="$2" | |
BRANCH_NAME="PR-${ID}" | |
git checkout $TARGET_BRANCH | |
git branch -D $BRANCH_NAME | |
git fetch upstream pull/$ID/head:$BRANCH_NAME | |
git checkout $BRANCH_NAME | |
else | |
echo "Usage: $0 <TARGET_BRANCH> <ID>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation Steps
cd ~/Downloads
)chmod +x ./git-pull-pr.sh
/usr/local/bin
to PATH (if not done before)~/.bash_profile
:/usr/local/bin
to thePATH
variable by adding/usr/local/bin
to the front of the string followed by a colon (:
)export PATH
setting, just add the following to the first line of your file:git-pull-pr <DEV> <PULL_REQUEST_ID>
from a git directory to create a new branchPR-<PULL_REQUEST_ID>
.