Why does cherry pick always lead to a merge conflict?

I am cherry picking specific commits from the release branch in my local working copy. Every time I cherry pick a commit from the release branch, I get a merge conflict that I have to solve, even with changes that seem trivial, for example:

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

is the only change made to commit on 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?

+3
source share
1 answer

Because, since the two branches diverge:

  • branch
  • dev changed the line using const char kApplicationVersion[] = "Develop";
  • rel branch changed the line using const char kApplicationVersion[] = "Release";

Cherry picking will allow merging with a common ancestor, but will not create the actual merge for this file (this means that the common ancestor remains a much older version, where the dev branch starts with the release branch).

The next cherry cyber will consider the same old common ancestor and cause the same merge conflict.

See (many) more in Conflict with Git merging or freezing, how are BASE (the so-called "ancestor"), LOCAL, and REMOTE defined? "

+3
source

All Articles