Skip to content

Instantly share code, notes, and snippets.

@shapr
Created November 26, 2018 18:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shapr/632015d6dd353fe3d0a7ccc4b3668ba0 to your computer and use it in GitHub Desktop.
Save shapr/632015d6dd353fe3d0a7ccc4b3668ba0 to your computer and use it in GitHub Desktop.
[alias]
# Checkout a pull request branch on an upstream project. It
# handles PRs that get rebased as well.
#
# git pr 3
pr = "!f() { git checkout master; git branch -D pr/$1 || true; git fetch origin refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
dpr = "!f() { git checkout develop; git branch -D pr/$1 || true; git fetch upstream refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
pur = "!f() { git checkout master; git branch -D pr/$1 || true; git fetch upstream refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
# Pull a rebasing branch on a fork. Useful for viewing someones
# rebasing feature branch from a clone of their fork.
pbr = "!f() { b=$(git rev-parse --abbrev-ref HEAD); git fetch origin $b && git reset --hard origin/$b; }; f"
# Really really clean checkout. Just shy of a completely fresh
# clone.
squeaky-clean = "!f() { git reset --hard && git clean -dxff; git submodule foreach git squeaky-clean; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment