简体   繁体   English

多个分支的合并顺序

[英]Merge Order Of Multiple Branches

I'm having some trouble figuring out the best order of merging branches to avoid merge conflicts and easier code reviews.我在确定合并分支的最佳顺序以避免合并冲突和更轻松的代码审查时遇到了一些麻烦。 I'm going to use the following picture to diagram my situation.我将使用下面的图片来描绘我的情况。

在此处输入图像描述

As you can see, I made Branch V from master, and added some commits.如您所见,我从 master 制作了 Branch V,并添加了一些提交。 Then I also have Branch K which was branched off of Branch V, and also has some commits.然后我还有从分支 V 分支出来的分支 K,也有一些提交。 I want to have two merge requests up for people to review, so my original plan was to have Branch K set to merge into Branch V, and then Branch V to merge into master.我想有两个合并请求供人们审查,所以我最初的计划是将分支 K 设置为合并到分支 V,然后将分支 V 合并到主分支。

Is that the best strategy?这是最好的策略吗? I didn't want to set Branch K to merge into master, because in the code review, the diff between Branch K and master includes differences that were made Branch V's commits.我不想将 Branch K 设置为合并到 master,因为在代码审查中,Branch K 和 master 之间的差异包括 Branch V 提交的差异。

I just really want to know what the best merge order is.我真的很想知道最好的合并顺序是什么。 Thanks!谢谢!

Yes, making one PR from V to master and another from K to V makes the most sense from the point of view of making those PRs easy to review , as each PR will only show its relevant code changes.是的,从使这些 PR 易于审查的角度来看,使一个 PR 从Vmaster和另一个从KV是最有意义的,因为每个 PR 只会显示其相关的代码更改。 And I would argue that making life easier on reviewers should be your top priority.我认为让审稿人的生活更轻松应该是你的首要任务。

Once these PRs are approved for merge you could either:一旦这些 PR 被批准合并,您可以:

  1. first merge K -> V and then V -> master首先合并K -> V然后V -> master
  2. first merge K -> master and then change the base of the other PR to master and merge it as well首先合并K -> master然后将另一个 PR 的基础更改为master并合并它

for option 2. to work well, K needs to make sense on its own, because you shouldn't at any point merge something broken into master对于选项 2. 要正常工作, K需要自己有意义,因为您在任何时候都不应该将损坏的东西合并到master

if you choose option 1. I would also suggest to edit the V -> master PR description after the merge of K to reflect that it now holds more (approved) changes如果您选择选项 1。我还建议在合并K后编辑V -> master PR 描述,以反映它现在拥有更多(已批准)的更改

and in general I would suggest to use the PR description to describe the relation between the two PRs in order to give the reviewers the full picture总的来说,我建议使用 PR 描述来描述两个 PR 之间的关系,以便为审阅者提供全貌

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

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