1

I'm trying to merger some specific (not all) from dev to master. And Used below command which throws exception.

C:\Users\arrchana\New_Code\Paymentev\AmazonPaymente2etestserv\A2paymente2etestservService> git cherry-pick 5dc6112 error: Commit 5dc6112 is a merge but no -m option was given. fatal: cherry-pick failed 

How to resolve this issue? Is there any other way to get the specific commit from dev and merge it with Master branch?

4
  • 4
    Possible duplicate of git cherry-pick says "...38c74d is a merge but no -m option was given" Commented Feb 8, 2019 at 3:51
  • You cannot cherry pick a merge, because cherry picking applies the changes a commit made compared to its parent and a merge has two parents (which one should git pick?). Cherry pick one of the merge parents instead. See the question I linked above for more info Commented Feb 8, 2019 at 3:52
  • Is there any other way to achieve this without using cherry-pick command? Commented Feb 8, 2019 at 4:21
  • @CaiusJard Note: that might change with Git 2.21: stackoverflow.com/a/34782687/6309 Commented Feb 8, 2019 at 6:08

1 Answer 1

2

You're trying to cherry pick a merge commit. While that can be done, it is most likely not what you want.

If you're trying to apply the changes from a specific range of commits, you will need to find the commit-ish (tags or sha1-hashes) for all of those commits by looking at the log.

You can then run git cherry-pick hash1 hash2 hash3.... Make sure those hashes are in the order in which they were committed!


If your specific change is within a merge commit, it gets harder.

First: Don't make any changes other than resolving conflicts in a merge commit!

With that out of the way: You can git diff 5dc6112 the merge commit or git show 5dc6112 to see if that contains your relevant changes. If it does, go:

git [diff/show] 5dc6112 | patch -p1 

this will apply the diff to your current working directory. You can then commit those changes.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.