问题
比如我们在 develop 分支执行下面的合并命令,去合并其他分支之后,我们突然不想合并了,要取消该怎么处理?
执行合并之后,会出现 MERGING
代码也有很多的变更
解决
我们可以执行
git merge --abort
官网是这样介绍这个命令的:我用谷歌翻译了一下
The second syntax (“git merge --abort”) can only be run after the merge has resulted in conflicts. git merge --abort will abort the merge process and try to reconstruct the pre-merge state. However, if there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), git merge --abort will in some cases be unable to reconstruct the original (pre-merge) changes. Therefore:
Warning: Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.
git merge --abort 只能在合并导致冲突后运行。 git merge --abort 将中止合并过程并尝试重建预合并状态。 但是,如果在合并开始时有未提交的更改(特别是如果在合并开始后进一步修改了这些更改), git merge --abort 在某些情况下将无法重建原始(合并前)更改。
执行完成之后,我们发现 MERGING 没了
代码也恢复到之前的状态了: