Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull a pull request from upstream in github

I have forked a repo in github. There are some new pull requests in the Upstream. I want to pull a pull request from upstream locally.

How can I do that? I have no idea and found nothing related to this.

like image 668
Noor A Shuvo Avatar asked Jan 04 '19 06:01

Noor A Shuvo


2 Answers

You should be able to do this by first adding the upstream as remote, and then pulling the pull request:

git remote add upstream https://github.com/USER/repository.git
git pull upstream pull/ID/head:BRANCHNAME
git checkout BRANCHNAME

Where USER is not your username but the original one (the one you forked from), ID is the pull-request id and BRANCHNAME will be the local branch name corresponding to the pull-request.

If you want to push to your own fork later, you will likely have to set the upstream (from BRANCHNAME):

git push -u origin BRANCHNAME
like image 155
Holt Avatar answered Sep 29 '22 13:09

Holt


See https://help.github.com/articles/checking-out-pull-requests-locally/:

git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME

where ID is the pull request number and BRANCHNAME is an arbitrary name for the new local branch.

like image 25
Anders Kaseorg Avatar answered Sep 29 '22 13:09

Anders Kaseorg