Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does cherry-pick always result in a merge conflict?

Tags:

git

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?

like image 554
JuJoDi Avatar asked Jul 15 '14 15:07

JuJoDi


1 Answers

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?"

like image 55
VonC Avatar answered Nov 15 '22 11:11

VonC