I know git cherry-pick
is a command that use to apply the changes of specified commit, but I think I just don't really understand the way it works.
Let's say a repo act like that:
git init
echo a>a
git add .; git commit -am 'master add line a'
git checkout -b dev
echo b>>a
git commit -am 'dev add line b'
echo c>>a
git commit -am 'dev add line c'
git checkout master
git cherry-pick dev
I thought cherry-pick
command would work well and change file a
into:
a
c
but in fact I got the following message:
error: could not apply 08e8d3e... dev add line c
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
And then I run:
git diff
output:
diff --cc a
index 7898192,de98044..0000000
--- a/a
+++ b/a
@@@ -1,1 -1,3 +1,6 @@@
a
++<<<<<<< HEAD
++=======
+ b
+ c
++>>>>>>> 11fff29... abc
So my question is: Why is there a conflict like git-diff shows? What are the details of cherry-pick working in this case?