哪个提交散列来撤消使用git-revert的推送合并? [英] Which commit hash to undo a pushed merge using git-revert?

查看:335
本文介绍了哪个提交散列来撤消使用git-revert的推送合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将beta分支合并到master分支中。我推动起源。我现在希望主人能够像在本地和远程合并之前一样。



撤销已经推送的合并建议

  git revert -m 1 commit_hash 

如果这确实是要走的路,我该如何确定 commit_hash ?我没有成功尝试 merge-base

  $ git merge-base --all master beta 
1f4b949b7ef97abf913ae672e3acd0907abfac1b
$ git恢复-m 1 1f4b949b7ef97abf913ae672e3acd0907abfac1b
错误:Mainline被指定,但提交1f4b949b7ef97abf913ae672e3acd0907abfac1b不是合并。
致命:恢复失败

我已经检查了git-log和gitk格式分支机构,但是它们很长,而且我很难确定我的解释,认为我应该寻求协助,然后才能做出更大的混乱。 Beta源自v2,源于master。由于我已经将新分支与主人保持同步,所以一路上已经有一些主人并入v2和beta。从beta版到master版本的合并是我想纠正的一个错误。

一旦我确定了合并点,如果我发现任何提交合并,真的应该在测试版分支上,移动它们的最佳方式是什么?

解决方案

您需要找到合并提交, git merge-base 告诉你可以进行合并的提交。它基本上是这两个分支中存在的最后一个提交。合并提交仅存在于您的主分支中,除非您在合并后创建了新分支,但这与此处不相关。 :)

查找合并提交尝试:
git log master ^ beta --ancestry-path --merges $ b

所需的提交是最后一次提交。



但请阅读Linus'写下: http:// www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt


I merged the beta branch into the master branch. I pushed to origin. I now want master to be as it was prior to the merger both locally and remotely.

A good answer for undoing a merge that was already pushed suggests

git revert -m 1 commit_hash

If this is indeed the way to go, how can I determine commit_hash? I unsuccessfully tried the hash returned by merge-base:

$ git merge-base --all master beta
1f4b949b7ef97abf913ae672e3acd0907abfac1b
$ git revert -m 1 1f4b949b7ef97abf913ae672e3acd0907abfac1b
error: Mainline was specified but commit 1f4b949b7ef97abf913ae672e3acd0907abfac1b is not a merge.
fatal: revert failed

I've examined both git-log and gitk renditions of the branches, but they're very long, and I am uncertain enough of my interpretation to feel I should seek assistance before making a perhaps bigger mess. Beta was derived from v2 which was derived from master. There have been some mergers from master into v2 and beta along the way as I've kept the new branches up-to-date with master. The merger in the direction from beta into master was a mistake I wish to correct.

Once I do determine the merge point, if I find any commits made on master after the merger that really should be on the beta branch, what's the best way to move them over?

解决方案

You need to find the commit of the merge, git merge-base tells you the commit where you can do the merge. It basically is the last commit that exists in those two branches. The merge commit exists in your master branch only, unless you created a new branch after the merge, but that's not relevant here. :)

To find the merge commit try: git log master ^beta --ancestry-path --merges

The needed commit is the very last commit.

But please read up on Linus' write up: http://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt

这篇关于哪个提交散列来撤消使用git-revert的推送合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆