如何恢复已经推送到远程分支的合并提交

如何恢复已经推送到远程分支的合并提交

本文介绍了如何恢复已经推送到远程分支的合并提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git revert< commit_hash> 本身不起作用。 '-m'必须指定,我对此很困惑。



以前有谁经历过这种情况?

-m 选项指定父号码。这是因为合并提交具有多个父代,并且Git不会自动知道哪个父代是主线,哪个父代是您想要合并的分支。



git log 的输出中查看合并提交时,你会看到它的父母列在以 Merge $ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $作者:Ben James< ben @ example.com>
日期:8月17日星期三22:49:41 2011 +0100

合并分支'gh-pages'

冲突:
自述文件

在这种情况下, git revert 8f937c6 -m 1 will让它像在 8989ee0 > git revert -m 2 中一样将树恢复为原来的状态 7c6b236


git revert <commit_hash> alone won't work. '-m' must be specified, and I'm pretty confused about it.

Anyone experienced this before?

解决方案

The -m option specifies the parent number. 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.

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:

commit 8f937c683929b08379097828c8a04350b9b8e183
Merge: 8989ee0 7c6b236
Author: Ben James <[email protected]>
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.

这篇关于如何恢复已经推送到远程分支的合并提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:52