简体   繁体   English

Git 分支:轻松将第三个分支合并为两个冲突的分支

[英]Git branching: easily merging a third branch into two conflicting branches

I have the following situation in git: One "stable" branch and one "unstable" branch.我在 git 中有以下情况:一个“稳定”分支和一个“不稳定”分支。 The unstable branch contains bugs which I try to find by running both the stable and unstable branches on the same input and comparing their output logs.不稳定分支包含我试图通过在同一输入上运行稳定分支和不稳定分支并比较它们的输出日志来找到的错误。

Now, my logging framework is not good enough for this debug.现在,我的日志框架不足以进行此调试。 So I want to improve my logging class.所以我想改进我的日志类。 I create a new branch, "log_improve" from "stable".我从“稳定”创建了一个新分支“log_improve”。 After I'll finish working on it, I'll merge it back to "stable".在我完成它的工作后,我会将它合并回“稳定”。 Up to here all is great.到这里一切都很棒。

My question is: How can I merge "log_improve" with the "unstable" branch while completely avoiding all the "stable/unstable" conflicts?我的问题是:如何在完全避免所有“稳定/不稳定”冲突的同时将“log_improve”与“不稳定”分支合并? I'm only interested in the changes "log_improve" did to the logger class, which is separate from the code "stable" and "unstable" disagree upon.我只对“log_improve”对记录器类所做的更改感兴趣,它与“稳定”和“不稳定”不同意的代码分开。

I'd say, get rid of the conflicts.我会说,摆脱冲突。 The merge that creates the conflicts (unstable -> stable) is not committed yet (can't be, as long as you have conflicts);产生冲突的合并(不稳定 -> 稳定)尚未提交(不能提交,只要你有冲突); so just reset your working directory, and merge log_improve into first one, then the other of the working branches.所以只需重置您的工作目录,然后将 log_improve 合并到第一个,然后再合并到另一个工作分支。 Then try the unstable -> stable merge again.然后再次尝试不稳定 -> 稳定合并。

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

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