error: commit is a merge but no -m option was given

I think the help/man page explains pretty clearly why you need the -m parameter and the error message pretty clearly specifies that you need it:

-m parent-number, --mainline parent-number Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.


I've had this same error when using git revert to revert a merge (feature branch which turned out to be bad). The -m is a bit confusing. Its not looking for a message. I think it just wants to know how far back from the given commit you want to revert (how many commits to revert)

Most of the time it's just 1. I.e. you only want to go back to the commit before your merge (the commit hash I'm providing). So the solution is:

git revert -m 1 <git_hash_for_merge>

Tags:

Git