Search code examples
gitgit-cherry-pickgit-cherry

Git: Cherry-pick adding code that not in the commit


I am using cherry pick to add commits from my branches on github. I have a branch with only one commit and that is related to creating a new function. when, I try to add that commit using cherry-pick, I got a conflict with 3 incoming funcitons!

 git cherry-pick 15sh -- no-commit

and the same commit in my PR on github is only adding one function, but got 3 function conflict!. It's imply adding two other funcitons from another PR!


Solution

  • It's imply adding two other funcitons from another PR!

    Not really. The content of the conflicting portion does not in any way imply that you need to copy it over. Do this: git cherry-pick --abort then run the same cherry-pick but set merge.conflictStyle to diff3 with git -c merge.conflictStyle=diff3 cherry-pick blahblah. Then see what changed between the middle block and the bottom block... that's what you need to see how to bring over into the upper block.