Reputation: 29497
I am using git cherry-pick
to add specific commit SHAs to a particular branch:
git cherry-pick 12345
error: commit 12345 is a merge but no -m option was given.
fatal: cherry-pick failed
(Pretend 12345
is a commit SHA.)
I've tried several other variations but they all fail:
git cherry-pick 12345 -m
git cherry-pick -m 12345
etc.
Not sure how to interpret the error message or figure out what the fix is. Any ideas?
Upvotes: 1
Views: 3096
Reputation: 17381
Yes, the sequence of commits passed to git cherry-pick indeed matters.
Consider your first commit A
introduced a new line, and the next commit B
modified the same line. if the commits are picked in the wrong order, then commit B
has nothing to patch, even if that didn't fail, then commit A
would add the un-patched line back, probably not what you want, right?
And regarding merge commits, if it introduced changes, then it must be included, too.
Also, usually you don't pass a long list of commits to git cherry-pick
, you can use revision range syntax to specify a series of commits, please refer to the EXAMPLES section in the manual: https://git-scm.com/docs/git-cherry-pick
Upvotes: 2