Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Last active January 21, 2019 08:08
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 adrienjoly/7e9fcd24727f1872007f39bd393d786c to your computer and use it in GitHub Desktop.
Save adrienjoly/7e9fcd24727f1872007f39bd393d786c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# inspiration: https://davidwalsh.name/pull-down-pr
# The `git pr` alias will checkout the branch associated to a given PR.
# Usage: `$ git pr 204`
git config --global --add alias.pr '!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'
# The `git pr-clean` alias will delete all the `pr/*` branches kept locally.
# Usage: `$ git pr-clean`
git config --global --add alias.pr-clean '!git checkout master ; 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