gpt4 book ai didi

Is there any way to avoid including branch history when resolving merge conflicts when cherry picking a commit(在选择提交时解决合并冲突时,有什么方法可以避免包括分支历史记录)

转载 作者:bug小助手 更新时间:2023-10-25 22:36:10 25 4
gpt4 key购买 nike



I have a branch structure like follows. 3 branches.

我有一个如下所示的分支结构。3个分支。


a - b - c - d  *main*
\
e - f *feature1*
\
h *feature2*

Feature1 and Feature2 are actually completely independent technically. I just wanted to test feature2 with feature1 code in there. But a change in plans mean I need to put feature2 into main before I put feature1 in.

Feature1和Feature2实际上在技术上是完全独立的。我只是想用Feature1代码测试Feature2。但是计划的更改意味着我需要在将Feature1放入Main之前将Feature2放入Main。


So the goal is to cherry pick h into d on main.

因此,我们的目标是在main上将h选为d。


Here is my sort of confusion. When I look at the diff in a viewer like Fork the diff is incredibly clean. In fact it is exactly what I would like to cherry pick. Just the line changes shown when I look at the changes in commit h.

这是我的困惑所在。当我在像Fork这样的查看器中查看diff时,diff是令人难以置信的干净。事实上,这正是我想要挑选的。当我查看Commit h中的更改时,只显示了行的更改。


The problem is that when I go to main and try to cherry pick in h it merge conflicts. And in that merge conflict is code from commits e and f which I guess technically makes sense as it is cherry picking the entire file state but makes cherry picking the commit much more difficult.

问题是,当我去Main并试图挑选它的时候,会合并冲突。在合并中,冲突是来自提交e和f的代码,我想这在技术上是有意义的,因为它是精挑细选整个文件状态,但使得精挑细选提交变得更加困难。


I tried saving commit h as a patch but it won't apply on d because of conflicts. I tried rebasing feature2 on main first but that has the same problem. Bottom line: the diff I see when I look at the diff for h is the exact diff I want to apply to d. Because there is a merge conflict it feels like the history of e and f are brought into the cherry picking of h. If I could somehow extract the diff of h on f and apply it to d that would be more what I am trying to do.

我尝试将Commit h保存为补丁,但由于冲突,它不适用于d。我首先尝试在Main上重新设置Feature2的基础,但也有同样的问题。一句话:当我查看h的diff时,我看到的diff正是我想要应用于d的diff。因为存在合并冲突,所以感觉e和f的历史被引入到h的樱桃挑选中。如果我能以某种方式提取h对f的diff,并将其应用于d,那将是我更想做的事情。


更多回答
优秀答案推荐

The conflict means that the changes in h build on changes in e and f. Since e and f are not in main, h cannot apply cleanly.

冲突意味着h中的变化建立在e和f中的变化之上。由于e和f不在main中,h不能完全应用。


There is a clear dependency between h and e+f, and that's what the conflict tells you.

在h和e+f之间有明显的依赖关系,这就是冲突告诉你的。


If the two features, Feature1 and Feature2 are conceptually/semantically independent, such that either can exist without the other, the conflict means that the implementations are textually interleaved or coupled and cannot be separated automatically (eg, one subroutine implements two distinct features). You'll need to resolve the conflict. When you eventually merge Feature1 into main, you'll have another conflict.

如果Feature1和Feature2这两个功能在概念上/语义上是独立的,使得任何一个都可以在没有另一个的情况下存在,则冲突意味着实现在文本上是交错的或耦合的,并且不能自动分离(例如,一个子例程实现两个不同的功能)。你需要解决冲突。当您最终将Feature1合并到Main中时,您将会遇到另一个冲突。


The conflict seems like a pain, but it tells something about the quality of the code, ie, that distinct features are not well separated. Rewrite it.

冲突看起来像是一种痛苦,但它揭示了代码的质量,即不同的功能没有很好地分开。重写一遍。


更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com