git 提交冲突

git提交后发生冲突:To https://gitee.com.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to ‘https://gitee.com/men_zi_qi/practical-training.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
在这里插入图片描述
产生原因:同一个项目,不同员工操作相同位置提交后发生冲突。

解决方法:

按照它的提示:

  1. git pull origin dev
    在这里插入图片描述
    它尝试自动合并后失败了,说需要去手动合并。

  2. 去代码中看,会发现多出来一段神奇的代码
    在这里插入图片描述

以上代码是 员工A和员工B同时提交造成的

  1. 以下所框起来的代码就是产生冲突的代码
    HEAD自己的代码;=======远程的代码
    List item

  2. 手动删除 并合并 解决冲突
    List item

  3. 命令行再次提交:搞定

git add .
git commit -m '解决冲突了啊哈'
git push origin dev
  • 1
  • 2
  • 3

在这里插入图片描述

  1. 正常流程需另一位提交员工:git pull origin dev 完美
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值