Why is cherry picking trying to apply past commits?

38 Views Asked by At

I have never cherry pick before. To experiment I did I have a master branch where a file has some contents. Over there there are commits "3" and commits "4" (fictional numbers, in reality they are commit ids) where each one adds one line to the file

commit "3" adds "this is commit 3" commit "4" adds "this is commit 4"

I went back to master and did

git cherry-pick 4

and I expected to easily add "this is commit 4" to the file but instead I got a conflict where there are two options (none of them the desired behavior)

Auto-merging onemoredoc.txt
CONFLICT (content): Merge conflict in onemoredoc.txt
error: could not apply 4... add line with 4
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'

current change : nothing

incoming change: both line "this is commit 3" and "this is commit 4"

Why? and how can I just add "this is commit 4" to the master

0

There are 0 best solutions below