The -m
option specifies the parent number .
(-m
选项指定父编号 。)
This is because a merge commit has more than one parent, and Git does not know automatically which parent was the mainline, and which parent was the branch you want to un-merge. (这是因为合并提交有多个父项,而Git不自动知道哪个父项是主线,哪个父项是要取消合并的分支。)
When you view a merge commit in the output of git log
, you will see its parents listed on the line that begins with Merge
:
(当您在git log
的输出中查看合并提交时,您会看到其父级在以Merge
开头的行中列出:)
commit 8f937c683929b08379097828c8a04350b9b8e183
Merge: 8989ee0 7c6b236
Author: Ben James <ben@example.com>
Date: Wed Aug 17 22:49:41 2011 +0100
Merge branch 'gh-pages'
Conflicts:
README
In this situation, git revert 8f937c6 -m 1
will get you the tree as it was in 8989ee0
, and git revert -m 2
will reinstate the tree as it was in 7c6b236
.
(在这种情况下, git revert 8f937c6 -m 1
将让你的树,因为它是在8989ee0
和git revert -m 2
将恢复树,因为它在7c6b236
。)
To better understand the parent IDs, you can run:
(为了更好地了解父ID,可以运行:)
git log 8989ee0
and
(和)
git log 7c6b236
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…