Skip to content

Instantly share code, notes, and snippets.

@willcl-ark
Created April 23, 2020 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willcl-ark/77512bac7facae3d351f6d7d46efef37 to your computer and use it in GitHub Desktop.
Save willcl-ark/77512bac7facae3d351f6d7d46efef37 to your computer and use it in GitHub Desktop.
git aliases to checkout and remove PRs easily
# Add this section to your global ~/.gitconfig file
[alias]
pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
pr-clean = "!git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
spr = "!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull-requests/$1/from:pr/$1 && git checkout pr/$1; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment