Found the solution! What's happening is that the cherry-pick
does not create a new merge-base (so they both share a common ancestor, but it was different than both of their current states). Therefore, when I modified master after the cherry-pick
, all three of my files were different. To visualize:
Common Ancestor:
File.txt: this is the common ancestor.
Then I make changes on secondary branch, and commit them.
Secondary:
File.txt: now I've modified this file to be this!
Then I git checkout master
and git cherry-pick [commit made on secondary]
.
Master:
File.txt: now I've modified this file to be this!
However, the common ancestor is still File.txt: this is the common ancestor.
If I make a commit on master, changing it to File.txt: now this is the new master!
, I would have three different versions of File.txt
! Thus, when I tried to merge, git complained about conflicts because it wasn't sure how to combine the two different files. To solve this, simply run git merge secondary
directly after the cherry-pick
while on master! So if we do this merge now, we get:
Common Ancestor:
File.txt: now I've modified this file to be this!
It seems non intuitive because the merge between master and secondary doesn't actually do anything to their files, since they are identical at this point. However, it is necessary to do this merge to create a common ancestor before we make anymore changes to either branch. Hope this helps someone!