菜鸟笔记
提升您的技术认知

Git revert merge会出现的问题

比如当我们git revert的时候,

git revert 

Git会抱怨:

is a merge but no -m option was given

这是因为你revert的那个commit是一个merge commit,它有两个parent, Git不知道base是选哪个parent,就没法diff,所以就抱怨了,所以你要显示告诉Git用哪一个parent。

git revert sidsad8 -m 1

这样就选parent 1,那么parent 1又是哪一个呢?

一般来说,如果你在master上mergezhc_branch,那么parent 1就是master,parent 2就是zhc_branch.

Often this will be parent number one, for example if you were on master and did git merge unwanted and then decided to revert the merge of unwanted. The first parent would be your pre-merge master branch and the second parent would be the tip of unwanted.