Skip to content

Instantly share code, notes, and snippets.

@spmason
Last active September 22, 2023 08:41
Show Gist options
  • Save spmason/7889481 to your computer and use it in GitHub Desktop.
Save spmason/7889481 to your computer and use it in GitHub Desktop.
Checkout PRs. I'm not sure where I got this from but I can't take credit for it
# Checks out a PR to a pr/<number> local branch
# Usage: git pr <number> [<upstream>]
git config --global alias.pr '!git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1 && :'
# Deletes pr/<number> branches
# Usage: git pr-clean
git config --global alias.pr-clean '!git for-each-ref refs/heads/pr/* --format='"'"'%(refname)'"'"' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment