0

I am trying to cherry-pick one of the commit using the sha to my branch but its giving error.

Say I am on branch x, then I am running the command git cherry-pick as560aad0138.... in my terminal.

The error I got is like this;

error: Commit as560aad0138.... is a merge but no -m option was given.
fatal: cherry-pick failed
Sam
  • 1,463
  • 1
  • 17
  • 28
  • 4
    Possible duplicate of [git cherry-pick says "...38c74d is a merge but no -m option was given"](http://stackoverflow.com/questions/9229301/git-cherry-pick-says-38c74d-is-a-merge-but-no-m-option-was-given) – Tim Biegeleisen Sep 13 '16 at 07:22
  • 1
    Use `git cherry-pick -m 1 as560aad` or `git cherry-pick -m 2 as560aad`, depending on which parent of the merge commit you want to use. – Tim Biegeleisen Sep 13 '16 at 07:22

1 Answers1

2

The answer is right there, in the error message.

From man git cherry-pick:

[...] -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. [...]

chelmertz
  • 19,026
  • 4
  • 40
  • 45
  • 1
    I wouldn't have answered this question, since it's a duplicate, but if you want to answer you should at least explain/recommend which parent the OP should choose. – Tim Biegeleisen Sep 13 '16 at 07:23
  • Considering I answered it the same time you looked up the duplicate, that's kind of a moot argument. Further, since you are not the OP, you do not know if the information in my answer is enough or not (I think it's enough, that's why I posted it). I will answer OP's comments if he has any. Even further, you posted a response as a comment to the question, which is silly even according to SO. If you think I'm being rude, it's because I found your comment slightly offensive but still wanted to dissect it. Have a good day. – chelmertz Sep 13 '16 at 08:14
  • 1
    I didn't mean to offend you. We have all answered duplicates from time to time, I was more trying to suggest that if you discussed the merge strategy in your answer, it would be unique and therefore the question would not be just a duplicate of what has been listed. – Tim Biegeleisen Sep 13 '16 at 08:16
  • 1
    @TimBiegeleisen Now that I read the accepted answer that you linked to, I really think that gave a fine use case. Sorry for being grumpy and thanks for replying! – chelmertz Sep 13 '16 at 08:24