git cherry-pick says ...38c74d is a merge but no -m option was given
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
This error appears when you try to cherry-pick a merge commit. Merge commits have two (or more) parents, and Git does not know which parent to use as the baseline for computing the diff. The fix is to specify the parent with the -m flag: git cherry-pick -m 1 <commit>. In most cases, -m 1 is correct because parent 1 is the branch that received the merge.
Why Merge Commits Are Different
A regular commit has exactly one parent. When you cherry-pick it, Git computes the diff between that commit and its single parent, then applies that diff to your current branch. There is no ambiguity.
A merge commit has at least two parents. It represents the point where two branches were joined. The "changes" introduced by a merge commit depend entirely on which parent you compare against:
- Compared to parent 1 (the branch that ran
git merge), you see everything the merged branch contributed. - Compared to parent 2 (the branch that was merged in), you see everything the receiving branch had that the merged branch did not.
These are completely different diffs. Git refuses to guess, so it requires you to specify the parent explicitly.
Inspecting the Merge Commit
Before choosing a parent number, inspect the commit to understand its structure:
The output will include lines like:
The first parent line is parent 1, the second is parent 2. You can also visualize the context:
Using -m to Specify the Parent
The -m flag (short for "mainline") tells Git which parent to treat as the baseline:
When to Use -m 1 vs. -m 2
| Merge Scenario | -m 1 Replays | -m 2 Replays |
main merged feature | Changes from feature | Changes from main since branch point |
release merged hotfix | The hotfix changes | Everything on release the hotfix didn't have |
develop merged bugfix | The bugfix changes | Everything on develop the bugfix didn't have |
In the vast majority of cases, you want -m 1 because you are trying to bring in the changes that were introduced by the branch that was merged in.
Step-by-Step Workflow
Here is the complete workflow for cherry-picking a merge commit safely:
Handling Conflicts
Cherry-picking merge commits often produces more conflicts than cherry-picking regular commits because the diff can be large and the branch context is different. When conflicts occur:
If conflicts are extensive, consider the alternative approach of cherry-picking individual non-merge commits instead.
Alternative: Cherry-Pick Individual Commits
Often, cherry-picking the merge commit itself is not the best approach. If the merged branch contains 5 commits, you can cherry-pick each one individually:
This approach has several advantages:
| Approach | Conflict Complexity | Review Clarity | Granularity |
Cherry-pick merge with -m 1 | Higher (one large diff) | Shows as single commit | All or nothing |
| Cherry-pick individual commits | Lower (smaller diffs) | Each commit is separate | Pick only what you need |
The individual commit approach is especially useful when you only need some of the changes from the merged branch, or when you are backporting to a release branch with divergent history.
Reverting a Merge Commit
The same -m flag applies to git revert for merge commits:
This creates a new commit that undoes the changes introduced by the merged branch. Be aware that after reverting a merge, re-merging the same branch later requires extra steps because Git considers those commits already merged.
Using --no-commit for Review
If you want to inspect the cherry-picked changes before committing them, use --no-commit:
Safe Workflow for Shared Repositories
When working on shared branches like release or main, always cherry-pick on a temporary branch first:
This keeps the risky operation isolated and reviewable. If something goes wrong, you can delete the temporary branch without affecting the release branch.
Common Pitfalls
Forgetting the -m flag entirely. This produces the error message you are reading about. Every merge commit cherry-pick requires -m.
Choosing the wrong parent number. Using -m 2 when you meant -m 1 gives you the inverse set of changes. Always inspect the diff with git diff 38c74d^1..38c74d --stat before committing.
Assuming the cherry-picked result matches the original merge exactly. The cherry-pick replays a diff onto a different base. Files that were modified differently on your current branch will conflict or produce different merge results.
Cherry-picking a merge that includes many unrelated changes. If the merge commit bundles multiple features (for example, merging a long-lived develop branch), cherry-picking the whole thing brings all of those changes. Pick individual commits instead.
Not testing after the cherry-pick. The cherry-pick may apply cleanly but still break the build because of missing dependencies that were introduced in other commits from the merged branch.
Reverting a merge and then trying to re-merge. After git revert -m 1 <merge>, Git treats the original commits as already integrated. To re-merge, you need to revert the revert first: git revert <revert-commit>.
Summary
When Git says a commit "is a merge but no -m option was given," it needs you to specify which parent to use as the diff baseline. Use git cherry-pick -m 1 <commit> for the most common case where parent 1 is the receiving branch. Always inspect the commit's parents and the resulting diff before pushing. For complex merges, prefer cherry-picking individual non-merge commits from the feature branch. Work on temporary branches when cherry-picking onto shared branches to keep the operation safe and reviewable.

