3 ms·
I have this script: $ cat ~/bin/git-pr #!/bin/sh if [ $# -lt 1 ]; then exit -1 fi git fetch origin refs/pull/$1/head:pr/$1
by fishywang 4y ago
I have this script:
$ cat ~/bin/git-pr
#!/bin/sh
if [ $# -lt 1 ]; then
exit -1
fi
git fetch origin refs/pull/$1/head:pr/$1
So I can run `git pr <number>` to get `pr/<number>` branch created locally that I can checkout to.
- mook 4y agoYou can add to the set of refs that git pulls (via remote.origin.refs); so for me it's `git checkout pr/123/head` (or /merge) instead, without creating a local branch that you need to delete later.
- nurgasemetey 4y agoAlso there is github cli for checking out PR $ gh pr checkout {<number> | <url> | <branch>}
- hpb42 4y agoYou can also configure git to fetch the GitHub PR branches[0]. Add this line to your .git/config: fetch = +refs/pull/*/head:refs/remotes/upstream/pr/* This has to be done in each repository you have checked out locally, but maybe it is possible to also have this done globally. But I never tried to do it. [0] http://tiborsimko.org/github-local-handling-of-pull-requests.html http://tiborsimko.org/github-local-handling-of-pull-requests...