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.
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.
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
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.
The GitHub API supports merging a pull request on the server using a PUT request. So, you may do a PUT locally and merge a pull request.
But note that this just means that a merge happened on the server. If you were on some branch, say master
, and you remotely triggered a pull request, if you wanted the latest content you would still have to do a pull:
git pull origin master
Pull request is not a git feature it is a workflow and as such has to be followed if there is a need for replication. So the only way is to do the same locally.
git checkout featureA # as it has to be on origin
git checkout master/develop
git merge featureA
At this point you are in the state as the pull request.
Try this - do a
git pull
to ensure you have the latest changes in master, then while on the master branch, do a
git checkout <branch name >
to the desired that has the PR(pull request) and finally do a
git pull
while on that branch. I believe it should pull the current state of the brach that has a pull request.