Skip to content

Instantly share code, notes, and snippets.

@henninghall
Created February 12, 2023 13:04
Show Gist options
  • Save henninghall/7997047851b17063fc510281e6fed269 to your computer and use it in GitHub Desktop.
Save henninghall/7997047851b17063fc510281e6fed269 to your computer and use it in GitHub Desktop.
git command to checkout PR from another fork
git config --global alias.pr '!f() { if [ $# -lt 1 ]; then echo "Usage: git pr <id> [<remote>] # assuming <remote>[=origin] is on GitHub"; else git checkout -q "$(git rev-parse --verify HEAD)" && git fetch -fv "${2:-origin}" pull/"$1"/head:pr/"$1" && git checkout pr/"$1"; fi; }; f'
# Usage: git pr 123 (where 123 is the number of the pr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment