推送后恢复合并 [英] Revert a merge after being pushed

查看:137
本文介绍了推送后恢复合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行的步骤:

我有两个分支branch1和branch2,

  $ git branch  - 初始状态
$分支1

$ git结帐分支2
$ git pull origin分支1 - 步骤1

我解决冲突并做了一个

  $ git commit -m合并已解决

然后

  $ git checkout branch1 
$ git merge branch2
$ git push origin branch1

现在我意识到,在步骤1时,自动合并移除了一些代码,并且更改代码被推入,现在我想返回到我的初始状态以恢复任何changes.looking一些立即帮助?

解决方案

您可以恢复官方指南,但是这给Git留下了erroneou我们认为合并的提交仍然在目标分支上。

基本上你必须:

  git revert -m 1(合并提交的提交ID)


Steps i performed:

I have two branches branch1 and branch2,

$git branch --Initial state
$branch1

$git checkout branch2
$git pull origin branch1 --Step1

I resolve the conflicts and did a

$git commit -m "Merge resolved"

then

$git checkout branch1
$git merge branch2
$git push origin branch1

Now i realised that while being at step1, the auto merging removed some code and the change code was pushed, now i want to go back to my initial state in order to revert any changes.looking for some immediate help?

解决方案

You can revert the merge following the official guide, however this leaves Git with the erroneous belief that the merged commits are still on the target branch.

Basically you have to :

git revert -m 1 (Commit id of the merge commit)

这篇关于推送后恢复合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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