为什么樱桃挑选总是导致合并冲突? [英] Why does cherry-pick always result in a merge conflict?

查看:161
本文介绍了为什么樱桃挑选总是导致合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是樱桃选择从发布分支到我当地的工作副本的具体承诺。每当我从发行版分支挑选一个提交时,我都会遇到一个我必须解决的合并冲突,即使这些更改看起来微不足道,例如:

  -const char kApplicationVersion [] =Develop; 
+ const char kApplicationVersion [] =发布;

是提交给main.cc的唯一更改。



git status 显示

 您目前樱桃采摘承诺6f04be8。 
(修复冲突并运行git cherry-pick -continue)
(使用git cherry-pick --abort取消樱桃挑选操作)

unmerged paths:
(使用git add< file> ...来标记分辨率)

都被修改:src / appMain / main.cc

为什么总会有冲突?

解决方案

因为这两个分支有分歧:


  • dev分支已经修改了行 const char kApplicationVersion [ ] =开发;

  • rel分支修改了行 const char kApplicationVersion [] =Release;

    一个樱桃选择将解决对共同祖先的合并,但不会为此创建实际的合并文件(这意味着共同的祖先仍然是一个更老的版本,其中 dev 分支从 release 分支开始)



    下一个樱桃选秀会利弊想象着同一个老共同的祖先,并且会触发相同的合并冲突。



    更多地参见在Git樱桃挑选或rebase合并冲突中,BASE(又名祖先),LOCAL和REMOTE如何确定?


    I'm cherry picking specific commits from a release branch into my local working copy. Every time I cherry-pick a commit from the release branch I get a merge conflict which I have to resolve, even with changes that seem trivial, such as:

    -const char kApplicationVersion[] = "Develop";
    +const char kApplicationVersion[] = "Release";
    

    being the only change made in the commit to main.cc.

    git status shows

    You are currently cherry-picking commit 6f04be8.
      (fix conflicts and run "git cherry-pick --continue")
      (use "git cherry-pick --abort" to cancel the cherry-pick operation)
    
    Unmerged paths:
      (use "git add <file>..." to mark resolution)
    
        both modified:      src/appMain/main.cc
    

    Why is there always a conflict?

    解决方案

    Because since the two branches have diverged:

    • dev branch has modified the line with const char kApplicationVersion[] = "Develop";
    • rel branch has modified the line with const char kApplicationVersion[] = "Release";

    A cherry-pick will resolve the merge against the common ancestor, but won't create an actual merge for that file (meaning the common ancestor remains a much older version, where dev branch started from release branch)

    The next cherry-pick will consider the same old common ancestor and will trigger the same merge conflict.

    See (much) more at "In a Git cherry-pick or rebase merge conflict, how are BASE (aka "the ancestor"), LOCAL, and REMOTE determined?"

    这篇关于为什么樱桃挑选总是导致合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆