Tired of looking up what a PR branch is to merge, rebase, or checkout? With these few utils, you can
-
checkout PR 135:
checkout-pr 135
-
merge PR 135 into current branch:
merge-pr 135
-
rebase current branch on branch of PR 135:
rebase-on-pr 135
-
Install and setup github cli (https://github.com/cli/cli):
brew install gh gh auth
-
Paste the functions below to your ~/.zshrc or ~/.bashrc:
function prbranch { gh pr view $1 --json headRefName | jq -r .headRefName } function merge-pr { branch="$(prbranch $1)" git fetch origin "$branch:$branch" && git merge "$branch" } function rebase-on-pr { branch="$(prbranch $1)" git fetch origin "$branch:$branch" && git rebase "$branch" } function checkout-pr { branch="$(prbranch $1)" git fetch origin "$branch:$branch" && git checkout "$branch" }
-
Navigate to the repo dir and now you can use the commands at the top of this readme.