git 如何修改 GitHub 上的拉取请求以更改要合并的目标分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24159036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to modify a pull request on GitHub to change target branch to merge into?
提问by Moriarty
I have a pull request that is requesting a merge into master from my branch, but the owner wants me to change the request to merge into a different branch from my branch.
我有一个请求请求从我的分支合并到 master,但所有者希望我更改请求以从我的分支合并到不同的分支。
Is this possible? What are the possible solutions?
这可能吗?可能的解决方案是什么?
回答by VonC
Update August 2016: Change the base branch of a Pull Requestfinally allows for changing that branch.
(And this closes issue 18, which was 3 years old and had 1500+ comments)
2016 年 8 月更新:更改拉取请求的基本分支最终允许更改该分支。
(这关闭了第 18 期,它已有 3 年历史,有 1500 多条评论)
After you've created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch.
创建拉取请求后,您可以修改基本分支,以便将拉取请求中的更改与不同的分支进行比较。
Original answer:
原答案:
Since a PR cannot be edited in term of branch (see below), the easiest way would be to:
由于 PR 不能根据分支进行编辑(见下文),最简单的方法是:
- create a local new branch on top of your current branch
- push that new branch
- make a new PR with the right destination.
- close the previous PR
- reference the "old" pull request from the new one; eg.
Supersedes #123
(as commented below by Rivera)
- 在当前分支之上创建一个本地新分支
- 推送那个新分支
- 使用正确的目的地创建新的 PR。
- 关闭上一个 PR
- 从新的拉取请求中引用“旧的”拉取请求;例如。
Supersedes #123
(正如下面由Rivera评论的)
(original answer, valid only when creating the PR)
(原始答案,仅在创建 PR时有效)
You could try and chose another base branch, as in "Changing the branch range and destination repository" (Clicking on the Edit
button at the top of a PR page)
您可以尝试选择另一个基本分支,如“更改分支范围和目标存储库”(单击Edit
PR 页面顶部的按钮)
The easiest way of thinking about the branch range is this:
- the base branchis where you think changes should be applied,
- the head branchis what you would like to be applied.
Changing the base repository changes who is notified of the pull request.
Everyone that can push to the base repository will receive an email notification and see the new pull request in their dashboard the next time they sign in.
考虑分支范围的最简单方法是:
- 该基地分支是你想改变应该应用,
- 该盖分支是你想什么应用。
更改基本存储库会更改收到拉取请求通知的人。
每个可以推送到基础存储库的人都会收到一封电子邮件通知,并在下次登录时在他们的仪表板中看到新的拉取请求。
If you select as a base branchthe one that the original maintainer (the owner) wants, your PR should merge from your branch (unchanged) to the new base branch.
如果您选择原始维护者(所有者)想要的基础分支,您的 PR 应该从您的分支(未更改)合并到新的基础分支。
回答by mkcor
If your branch is (still) available remotely, you do not have to create a new branch locally.
如果您的分支(仍然)远程可用,则您不必在本地创建新分支。
Select your branch (which bears the changes you are submitting) either directly from the drop-down menu or under "# branches" (https://github.com/account/project/branches).
Click "New pull request". This lets you choose a new base (target) branch.
直接从下拉菜单中或在“#分支”(https://github.com/account/project/branches)下选择您的分支(包含您提交的更改)。
单击“新建拉取请求”。这让您可以选择一个新的基本(目标)分支。
Here is a screenshot of Github's new interface:
I can submit a PR of branch UX
against any fork/branch---it doesn't matter whether I previously submitted a PR for branch UX
.
我可以UX
针对任何 fork/branch 提交 branch 的 PR——我之前是否提交了 branch 的 PR 都没有关系UX
。
回答by MK.
You can now: https://github.com/blog/2224-change-the-base-branch-of-a-pull-request
您现在可以:https: //github.com/blog/2224-change-the-base-branch-of-a-pull-request
"You can now change the base branch of an open pull request. After you've created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch. By changing the base branch of your original pull request rather than opening a new one with the correct base branch, you'll be able to keep valuable work and discussion."
“您现在可以更改开放拉取请求的基础分支。创建拉取请求后,您可以修改基础分支,以便将拉取请求中的更改与不同的分支进行比较。通过更改拉取请求的基础分支您的原始拉取请求而不是使用正确的基本分支打开一个新的请求,您将能够保留有价值的工作和讨论。”
回答by Ani Thettayil
You have to create a new pull request as mentioned in the gibhub doc LINK
您必须创建一个新的拉取请求,如 gibhub doc LINK 中所述
- First select
New Pull request
- in the
compare page
, left side select thetarget branch
you want to push and right side select thebranch you already pushed
. - Update the details for your new
PR
. - Create the
PR
- 首先选择
New Pull request
- 在 中
compare page
,左侧选择target branch
要推送的 ,右侧选择branch you already pushed
。 - 更新您的新
PR
. - 创建
PR
回答by Golden Thumb
It's pretty simple. Just click the PR for which you want to change its base branch. Find "Close pull request" button near the bottom of the web page. Now you can recreate a new PR normally - make sure you select the correct base branch this time.
这很简单。只需单击要更改其基本分支的 PR。找到靠近网页底部的“关闭拉取请求”按钮。现在你可以正常重新创建一个新的 PR——确保这次你选择了正确的基础分支。