如何撤消冲突的git合并 [英] How to undo a git merge with conflicts

查看:149
本文介绍了如何撤消冲突的git合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在分支 mybranch1 中。 mybranch2 是从 mybranch1 分支的,并且在 mybranch2 然后,在 mybranch1 时,我已经完成了 git merge --no-commit mybranch2
它显示合并时存在冲突。



现在我想丢弃所有内容( merge 命令),以便 mybranch1 回到之前的状态。
我不知道该怎么做。

解决方案

最新的Git:

  git merge --abort 

这会尝试将工作副本重置为合并前的状态。这意味着它应该从合并之前恢复任何未提交的更改,尽管它并不总是如此可靠。通常情况下,您不应该合并未提交的更改。



在版本1.7.4之前:

  git reset --merge 

这是较旧的语法,但与以上。



版本1.6.2之前:

  git重置--hard 

删除所有未提交的更改,包括未提交的合并。有时候,即使在支持上述命令的新版Git中,这种行为也是有用的。


I am on branch mybranch1. mybranch2 is forked from mybranch1 and changes were made in mybranch2.

Then, while on mybranch1, I have done git merge --no-commit mybranch2 It shows there were conflicts while merging.

Now I want do discard everything (the merge command) so that mybranch1 is back to what it was before. I have no idea how do I go about this.

解决方案

Latest Git:

git merge --abort

This attempts to reset your working copy to whatever state it was in before the merge. That means that it should restore any uncommitted changes from before the merge, although it cannot always do so reliably. Generally you shouldn't merge with uncommitted changes anyway.

Prior to version 1.7.4:

git reset --merge

This is older syntax but does the same as the above.

Prior to version 1.6.2:

git reset --hard

which removes all uncommitted changes, including the uncommitted merge. Sometimes this behaviour is useful even in newer versions of Git that support the above commands.

这篇关于如何撤消冲突的git合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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