简体   繁体   English

如何从github上游拉取拉取请求

[英]How to pull a pull request from upstream in github

I have forked a repo in github. 我在github上分了一个回购。 There are some new pull requests in the Upstream . 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. 如果USER不是您的用户名而是原始用户名(您分配的用户名),则ID是pull-request id, BRANCHNAME将是与pull-request相对应的本地分支名称。

If you want to push to your own fork later, you will likely have to set the upstream (from BRANCHNAME ): 如果您想稍后推送到自己的分支,则可能必须设置上游(来自BRANCHNAME ):

git push -u origin BRANCHNAME

See https://help.github.com/articles/checking-out-pull-requests-locally/ : 请参阅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. 其中ID是拉取请求编号, BRANCHNAME是新本地分支的任意名称。

The GitHub API supports merging a pull request on the server using a PUT request. GitHub API支持使用PUT请求在服务器上合并拉取请求。 So, you may do a PUT locally and merge a pull request. 因此,您可以在本地执行PUT并合并拉取请求。

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: 如果你在某个分支上,比如说master ,并且你远程触发了一个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. Pull请求不是git功能,它是一个工作流,因此如果需要复制,必须遵循。 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 确保您拥有master中的最新更改,然后在master分支上执行

git checkout <branch name >

to the desired that has the PR(pull request) and finally do a 到期望有PR(拉动请求),最后做一个

git pull

while on that branch. 而在那个分支上。 I believe it should pull the current state of the brach that has a pull request. 我相信它应该拉动具有拉动请求的brach的当前状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM