git命令怎么取消合并?

简介: git命令怎么取消合并?

问题

比如我们在 develop 分支执行下面的合并命令,去合并其他分支之后,我们突然不想合并了,要取消该怎么处理?

a59d92edefc740d3ad26b4dfa59f38c6.png

执行合并之后,会出现 MERGING

68f2634092f743059edb791a828be603.png

代码也有很多的变更

02319152147241ca8ff5bb36c73053a6.png




解决


我们可以执行

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 在某些情况下将无法重建原始(合并前)更改。


8ca95c5f504b4780a762670d2f71f129.png


执行完成之后,我们发现 MERGING 没了


7b5566d6990a4f1da83b6c3f5ac57174.png



代码也恢复到之前的状态了:


f87ee323e39b4e45bd2395ff3935e263.png














目录
相关文章
|
14天前
|
缓存 数据可视化 网络安全
Git命令大全
Git命令大全
46 1
|
18天前
|
开发工具 git
Git教程:深入了解删除分支的命令
【4月更文挑战第3天】
37 0
Git教程:深入了解删除分支的命令
|
1月前
|
存储 Shell Linux
【Shell 命令集合 文件管理】Linux git命令使用教程
【Shell 命令集合 文件管理】Linux git命令使用教程
34 0
|
1月前
|
开发工具 git
git常用命令整理
git常用命令整理
13 0
|
24天前
|
开发工具 git 开发者
Git常用命令大全:让你轻松驾驭版本控制
Git命令速查:`git init`新建仓库,`git clone`克隆,`git add`入暂存区,`git commit -m`提交,`git status`查看状态,`git log`查看历史,`git branch`创建分支,`git checkout`切换,`git merge`合并,`git pull`拉取更新,`git push`推送,`git remote -v`查看远程,`git checkout --`撤销本地修改,`git reset HEAD`取消暂存,`git reset --hard`回退版本。掌握这些,提升代码管理效率!
18 0
|
3天前
|
存储 Linux 开发工具
Git 分布式版本控制系统基本概念和操作命令
Git 分布式版本控制系统基本概念和操作命令
21 0
|
5天前
|
算法 Java BI
云效产品使用报错问题之平台上导出的统计数据和 git 中使用命令导出的数据统计都对不上,如何解决
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
7天前
|
开发工具 git
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
17 0
|
1月前
|
算法 开发工具 git
【git 实用指南】git 增加 本地代码 git add 相关命令和复杂情况需求
【git 实用指南】git 增加 本地代码 git add 相关命令和复杂情况需求
93 0
|
1月前
|
Shell Linux 开发工具
【Shell 命令集合 系统管理 】Linux 查看当前Git仓库的提交历史 gitps命令 使用指南
【Shell 命令集合 系统管理 】Linux 查看当前Git仓库的提交历史 gitps命令 使用指南
18 0