PRO tip to merge GitHub pull-request into local repository easily.
How are you doing checkout GitHub pull-request on local repository?
$ git fetch origin pull/ID/head:BRANCHNAME
ID is pull-request number, BRANCHNAME is name of local branch you will create
Like this? Would you remember this format in tomorrow? Maybe I don't.
Thankfully GitHub serve some extra contents with appending file extension into URLs. See Diff and patch media types. For example, put .diff
to the end of pull-request URL:
"https://github.com/vim/vim/pull/2070" + ".diff"
https://github.com/vim/vim/pull/2070.diff
This request will be redirected to the page of unified diff
. If put .patch
to the URL of pull-request.
"https://github.com/vim/vim/pull/2070" + ".patch"
https://github.com/vim/vim/pull/2070.patch
This will be redirected to the patch file. So you can try to apply the diff like below.
$ curl -sL https://github.com/vim/vim/pull/2070.diff | patch -p1
Also if you want to merge pull-request into your local repository,
$ git checkout -b pr-2070
$ curl -sL https://github.com/vim/vim/pull/2070.patch | git am
Do tests and push into master branch.
$ git checkout master
$ git merge pr-2070
$ git push origin master
Can you see that? It's not difficult at all.
Top comments (0)