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?

ArrchanaMohan
  • 2,314
  • 4
  • 36
  • 84
  • 4
    Possible duplicate of [git cherry-pick says "...38c74d is a merge but no -m option was given"](https://stackoverflow.com/questions/9229301/git-cherry-pick-says-38c74d-is-a-merge-but-no-m-option-was-given) – Caius Jard Feb 08 '19 at 03: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 – Caius Jard Feb 08 '19 at 03:52
  • Is there any other way to achieve this without using cherry-pick command? – ArrchanaMohan Feb 08 '19 at 04:21
  • @CaiusJard Note: that might change with Git 2.21: https://stackoverflow.com/a/34782687/6309 – VonC Feb 08 '19 at 06:08

1 Answers1

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.

cfstras
  • 1,613
  • 15
  • 21