Skip to content

Instantly share code, notes, and snippets.

@msakrejda
Last active August 29, 2015 14:00
Show Gist options
  • Save msakrejda/3a689c89e6b0edfd3ef1 to your computer and use it in GitHub Desktop.
Save msakrejda/3a689c89e6b0edfd3ef1 to your computer and use it in GitHub Desktop.
automagic GitHub pull requests as remote branches
#!/bin/bash
# automagically clone with https://help.github.com/articles/checking-out-pull-requests-locally
# since this is only going to work on GitHub anyway, don't make the user specify the full URL
usage="Usage: $0 user/repo"
path="${1:?$usage}"
repo="$(basename "$path")"
git clone git@github.com:${path}
cd $repo
sed -i $'/fetch = +refs/a \\\tfetch = +refs\/pull\/*\/head:refs\/remotes\/origin\/pr\/*' .git/config
git remote update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment