I understand that cherry-pick was invented for apply some intermediate commits but does exist any difference between:
git cherry-pick last_commit_from_branch
and
git merge some_branch
As i understand, git will apply not only this one commit but also all previous commits starting with common commit? If yes, the only difference in these lines will be that in case of merge the new commit will have two parent commits from these branches.
These both commands are different in a very substantial way.
Lets start with git cherry-pick
:
diff
the commit introduceddiff
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.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?
A
and B
which is 2
in this case.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.