git代码合并了后发现有冲突,我们怎么取消合并?

项目场景:

git代码合并了后发现有冲突,我们有时候不想解决冲突,不想合并了;或者别人把冲突解决完了,自己想拉取一下最新代码,咋办呢?


解决方案:

使用命令行

git merge --abort

测试实现:

D:\cloud\ui-console (release/V3.4.1.1-20221122 -> origin)
λ git pull
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
From http://gitlab.rd.cloud.com/cloud/pco/ui-console
   31bb89ec..b010f16d  release/V3.4.4-20221130 -> origin/release/V3.4.4-20221130
Already up to date.

D:\cloud\ui-console (release/V3.4.1.1-20221122 -> origin)
λ git checkout release/V3.4.4-20221130
Switched to a new branch 'release/V3.4.4-20221130'
M       src/components/iam/logger/index.vue
Branch 'release/V3.4.4-20221130' set up to track remote branch 'release/V3.4.4-20221130' from 'origin'.

D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git pull
Already up to date.

【将release/V3.4.1.1-20221122分支代码合到release/V3.4.4-20221130分支】
【合并过程有了冲突了】
D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git merge release/V3.4.1.1-20221122 release/V3.4.4-20221130
Auto-merging src/components/workorder/orderDetail/components/order-detail-tab.vue
CONFLICT (content): Merge conflict in src/components/workorder/orderDetail/components/order-detail-tab.vue
Automatic merge failed; fix conflicts and then commit the result.

【别人提交的代码,自己不想解决冲突,让别人解决完冲突后自己拉取一下代码,发现有没有合并代码的错误】
D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git pull
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.

D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ

【使用git merge --abort 取消合并】
D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git merge --abort

【再进行git pull】
D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git pull
Updating b010f16d..0ceb5fad
Fast-forward
 src/components/expense/pay/openService.vue | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

D:\cloud\ui-console (release/V3.4.4-20221130 -> origin)
λ git pull
Already up to date.
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值