Cherry pick shows no -m option was given error

Akash Jain picture Akash Jain · May 2, 2016 · Viewed 32.1k times · Source

I have two branch master and development

I need to get some commit id from development branch in master branch so I do it by cherry-pick but it shows me some error

$> git cherry-pick cf0d52b

error: Commit cf0d52b900f990300c3aa17936ddbae1476d461a is a merge but no -m option was given.
fatal: cherry-pick failed

I am not getting this error, why this error comes and how will I get rid of this.

Answer

CodeWizard picture CodeWizard · May 2, 2016

You are trying to cherry-pick a merge. A merge is build up from at several parents. You have to supply the parent id to the merge.

You have to supply any of the followings:

-m parent-number / --mainline parent-number

Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline.

This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.


How to find out what are the commit parents?

Use the git show command to view the commit parents and then you can choose the parent index or the SHA-1

enter image description here