The git is requesting you to specify parent number (-m
), because your merge commit has two parents and git do not know which side of the merge should be considered the mainline. So using this option you can specify the parent number (starting from 1) of the mainline and cherry-pick in order to replay the change relative to the specified parent.
To find out your commit parents, try either:
git show --pretty=raw <merge_commit>
or:
git cat-file -p <merge_commit>
or even for better GUI visibility, try:
gitk <merge_commit>
As result, you should get something like:
commit fc70b1e9f940a6b511cbf86fe20293b181fb7821
tree 8d2ed6b21f074725db4f90e6aca1ebda6bc5d050
parent 54d59bedb9228fbbb9d645b977173009647a08a9 = <parent1_commit>
parent 80f1016b327cd8482a3855ade89a41ffab64a792 = <parent2_commit>
Then check your each parent details by:
git show <parent1_or_2_commit>
Add --stat
to see list of modified files.
Or use the following command to compare the changes (based on the above parent):
git diff <parent1_or_2_commit>..<commit>
Add --stat
to see list of modified files.
or use the combined diff to compare the two parents by:
git diff --cc <parent1_commit>
git diff --cc <parent2_commit>
Then specify the parent number starting from 1 for your cherry-pick, e.g.
git cherry-pick -m 1 <merge_commit>
Then run git status
to see what's going on. If you don't want to commit the changes yet, add -n
option to see what happens. Then when you're not happy, reset to HEAD (git reset HEAD --hard
). If you'll get git conflicts, you'll probably have to solve them manually or specify merge strategy (-X
), see: How to resolve merge conflicts in Git?