I forked a repo with a file that looks like this:
whatever
pizza
pasta
pesto
I then changed it to:
whatever
banana
pasta
pesto
And eventually an upstream commit changed it to:
whatever
pizza
pasta
cheese
pesto
And when I cherrypicked that commit, I had exactly what I wanted:
whatever
banana
pasta
cheese
pesto
And the question is... how does this process work?
That's crazy, I expected it to fail and say: "hey what is this file, I don't recognize it".
CodePudding user response:
How does this process work?
Cherry-pick is a merge, that's how.
It uses the commit before the cherry-picked commit (parent of "them") as the merge-base, diffs that with "them" and diffs it with "us", and enacts both diffs in a new commit created on top of "us". That's what merge logic is.
So if you diff
whatever
pizza
pasta
pesto
to:
whatever
banana
pasta
pesto
you see that pizza changed to banana. And if you diff
whatever
pizza
pasta
pesto
to:
whatever
pizza
pasta
cheese
pesto
you see that cheese was inserted between pasta and pesto. Can you enact both those changes? Yes!!! You get
whatever
banana
pasta
cheese
pesto
Which is exactly what you did get.
