These both commands are different in a very substantial way.
Lets start with git cherry-pick
:
- A cherry pick literaly takes the
diff
the commit introduced
- It literaly applies this
diff
on the HEAD
you are currently on. This means it doesn't take any parent commits into account to accomplish a smooth and correct merge.
- A cherry pick does not create any connection to the branch you are picking from. There is a reference to the commit you took it from, but this reference is only in the commit message.
Now lets take a look for what a merge does.(For the sake of simplicity we look a common 3-Way merge)
A
|
1--2--3--4
|
5--6--7
|
B
Now lets say you want to merge both of them. What will git now do?
- First it will try to find the most common ancestor of
A
and B
which is 2
in this case.
- It will now determine the changes brought in by
4
and 7
and match them agains 2
to get the difference for the merging. More in detail: If you have changes that are in 2
and in 7
it will take the changes from A
as the merge changes and vice versa.
So a merge has the possibility to take more information into account while doing the actual merge compared to a simple cherry-pick.