简体   繁体   English

Github 一个分支的一个分支的pull request

[英]Github pull request for a branch of a branch

My git log looks like this:我的 git 日志如下所示:

-------> develop
\---> A
    \---> B

Branch A is based off of develop, and is being reviewed in a pull request.分支 A 基于开发,正在拉取请求中进行审查。 In the meantime, I need to develop more stuff off of the branch, so I create Branch B. There is also a pull request for Branch B into develop, which includes the commits for both Branch A and Branch B.与此同时,我需要在分支之外开发更多东西,所以我创建了分支 B。还有一个分支 B 的拉取请求到开发中,其中包括分支 A 和分支 B 的提交。

The review of branch A finishes, and it is merged into develop, at which point, Github says that I need to merge develop into branch B, but if I do this, then usually it generates a lot of merge conflicts and can be difficult to untangle. branch A的review结束,合并到develop,这时Github说我要合并develop到branch B,但是如果我这样做,那么通常会产生很多合并冲突,很难解开。

Is there a way to do pull requests for both Branch A and B simultaneously, without Branch B's pull request getting confused when Branch A merges in?有没有办法同时对分支 A 和 B 进行拉取请求,而不会在分支 A 合并时混淆分支 B 的拉取请求?

I see a problem with the workflow here. 我在这里看到工作流程有问题。 Why are you merging a branch into something other than the branch it was created off? 为什么将分支合并到分支创建以外的其他内容中?

Changing the workflow like this can get everything working smoothly: 像这样更改工作流程可以使所有工作顺利进行:

  1. Create branch A off develop 在开发中创建分支A
  2. Make the changes (if there's any) that would be needed for developing the "more stuff" you referred to on a different branch 进行必要的更改(如果有的话),以开发您在其他分支上引用的“更多内容”
  3. Create branch B off A 从A创建分支B
  4. Go to the pull request for merging A into develop and leave a comment stating that you're developing more stuff on a branch created off A and want the reviewers to review as if A already had that stuff 转到将A合并到development的请求中,并留下一条评论,指出您正在A上创建的分支上开发更多的东西,并希望审阅者像A已有该东西一样进行审阅
  5. Develop the "more stuff" on B 在B上开发“更多内容”
  6. Create a PR for merging B into A just to make sure everything is reviewed 创建一个PR以将B合并为A,以确保所有内容都经过审查
  7. Merge B into A 将B合并为A
  8. Review everything one last time just in case 最后查看所有内容,以防万一
  9. Merge A into develop 合并开发

One solution may be to use the Github feature that allows you to change the base branch of a pull request . 一种解决方案是使用Github功能,该功能允许您更改拉取请求的基础分支 So the workflow looks like this: 因此,工作流程如下所示:

  1. Create Branch A off of develop 从开发创建分支A
  2. Do stuff on A 在A上做东西
  3. Create pull request for A to merge into develop 为A创建合并请求以合并到开发
  4. Create Branch B off of A 从A创建分支B
  5. Do stuff on B 在B上做东西
  6. Create pull request for B to merge into Branch A 为B创建合并请求以合并到分支A
  7. Merge Branch A when it is ready to go, and change Branch B's pull request to be based off of develop 准备好要合并分支A时,将B的拉取请求更改为基于开发
  8. Merge Branch B when it's ready to go. 准备好合并分支B。

Once you change Branch B's base, then I think Github should show the proper diffs, but haven't tested this yet. 一旦更改了B分支的基准,我认为Github应该显示适当的差异,但尚未对此进行测试。

Github says that I need to merge develop into branch B, but if I do this, then usually it generates a lot of merge conflicts and can be difficult to untangle. Github 说我需要将 develop 合并到分支 B,但是如果我这样做,通常会产生很多合并冲突并且很难解决。

Instead of a merge, rebasing B on top of develop could be less conflict-prone, if the change in refs isn't otherwise a problem for you.如果 refs 的更改对您来说不是问题,那么在 develop 之上重新设置 B 而不是合并,可能不会那么容易发生冲突。

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

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