简体   繁体   English

前一个未决合并时的新拉取请求

[英]New Pull Request when a previous one is pending Merge

I made some changes to several files of the project on a new branch (let's call it branch_a), I commited them, created the Pull Request, and it was recently reviewed and approved.我在一个新分支(我们称之为 branch_a)上对项目的几个文件进行了一些更改,我提交了它们,创建了拉取请求,并且它最近得到了审查和批准。 It's still pending Merge on the master branch.它仍在 master 分支上等待合并。

Now, someone asked for another change.现在,有人要求进行另一项更改。 It's a small supplemental change in 1 of the files edited in the first Pull Request.这是在第一个 Pull Request 中编辑的文件中的一个小的补充更改。

What's the best way of doing this?这样做的最佳方法是什么? Should I ask for the first Pull request to be merged and then create a new branch (branch_b), make my change and create a new Pull Request, ask for review and merge again?我是否应该要求合并第一个拉取请求,然后创建一个新分支(branch_b),进行更改并创建一个新的拉取请求,请求审查并再次合并? Or is there a "cleaner" way, when the first Pull Request is somehow merged with the second one and we don't have to make 2 different merges?还是有一种“更干净”的方式,当第一个拉取请求以某种方式与第二个合并时,我们不必进行 2 次不同的合并?

Branch off the first pull request branch, edit, add, commit, push, and ask for a second PR merging to the first branch .分支出第一个拉取请求分支,编辑、添加、提交、推送并请求第二个 PR 合并到第一个分支 When the first branch is merged the second PR will be reconfigured automatically (by GitHub) to be merged into the main branch.当第一个分支合并时,第二个 PR 将自动重新配置(由 GitHub)合并到主分支中。

If another change requested is a part of the same feature as in 'branch_a', then you can simply make change in the same branch, your PR request will show up those changes, but PR approval will be required again.如果请求的另一个更改是与“branch_a”中相同功能的一部分,那么您只需在同一个分支中进行更改,您的 PR 请求将显示这些更改,但将再次需要 PR 批准。

If another change requested is outside the scope of feature 'branch_a' and it is just a file is same between two changes, then you can create a new branch out of master say 'branch_b', complete your changes and raise PR for the same.如果请求的另一个更改在功能“branch_a”的 scope 之外,并且两个更改之间只是一个文件相同,那么您可以从 master 中创建一个新分支,例如“branch_b”,完成您的更改并为此提高 PR。 After 'branch_a' is merged into master, you can rebase your second branch 'branch_b' to include updated master codebase into branch_b, (or vice-versa if branch_b is merged first). 'branch_a' 合并到 master 后,您可以重新设置第二个分支 'branch_b' 以将更新的 master 代码库包含到 branch_b 中,(反之亦然,如果首先合并 branch_b)。 This is especially useful if the order of merge is not decided in advance.如果没有提前决定合并的顺序,这将特别有用。

Below are the steps, for rebase, here 'feature_branch' is the name of your branch for which you want to perform rebase:以下是 rebase 的步骤,这里 'feature_branch' 是您要执行 rebase 的分支的名称:

git checkout master
git pull origin master
git checkout feature_branch
git rebase master

Here you might get some conflicts(if there are any) multiple times as per number of commits in your feature_branch.在这里,根据您的 feature_branch 中的提交次数,您可能会多次遇到一些冲突(如果有的话)。 You can resolve the conflicts manually and proceed with further process of rebase with below command:您可以手动解决冲突,并使用以下命令继续进行 rebase 的进一步处理:

git rebase --continue

At any point if you think that things are not going well and you would like to cancel rebase process, then execute below command:在任何时候,如果您认为事情进展不顺利并且想取消 rebase 过程,请执行以下命令:

git rebase --abort

Finally when all conflicts are resolved and you get message as successfully merged, then execute below command to push changes to origin:最后,当所有冲突都解决并且您收到成功合并的消息时,然后执行以下命令将更改推送到源:

git push --force origin feature_branch

for more information on rebase process follow link: https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase有关 rebase 过程的更多信息,请点击链接: https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase

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

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