Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What value to give to -m switch in git revert?

Tags:

git

github

While issuing git revert <commit_hash> command i am getting error message as below:-

$ git revert e8801f7
error: commit e8801f7f3b800fee035693aa6bfd12868c15eec9 is a merge but no -m option was given.
fatal: revert failed

What value should i give to -m switch of git revert?

like image 722
Anuroop Avatar asked Nov 23 '17 12:11

Anuroop


1 Answers

-m switch is given to git revert command to tell Git to which parent commit the changes should be reverted back to. -m switch is not required when reverting a normal (non-merge) commit. It is required only while reverting a merge commit.

Follow the example below to understand the use of -m switch. Below is the git log of a recent merge commit that was created after resolving a conflict:-

enter image description here

Now:-

To revert back to parent 1 commit give below command:-

git revert -m 1 79f06e5

To revert back to parent 2 commit give below command:-

git revert -m 2 79f06e5
like image 113
Anuroop Avatar answered Nov 12 '22 16:11

Anuroop