问题描述
我是樱桃选择从发布分支到我当地的工作副本的具体承诺。每当我从发行版分支挑选一个提交时,我都会遇到一个我必须解决的合并冲突,即使这些更改看起来微不足道,例如: -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
分支开始)
下一个樱桃选秀会利弊想象着同一个老共同的祖先,并且会触发相同的合并冲突。
更多地参见
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
showsYou 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 fromrelease
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?"
这篇关于为什么樱桃挑选总是导致合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- dev branch has modified the line with