git冲突合并及强制推送
所属分类 git
浏览量 1510
造成冲突的原因
多人同时修改同一个地方 或者 分支合并冲突
分支合并
git merge branch-name
<<<<<<< HEAD
2019-07-05 08:33:55 @ master
=======
2019-07-05 08:31:40 @ develop
>>>>>>> develop
同一分支冲突时 无法 push
git push
To https://gitee.com/dyyx/gitdemo.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/dyyx/gitdemo.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.
使用 pull 然后 手工解决冲突
<<<<<<< HEAD
2017-07-05 08:48:55 @ gitdemo2
=======
2019-07-05 08:47:50 @ gitdemo1
>>>>>>> ad40ad0b548fb378e120e21488d338fa00e3a3a1
冲突时可以不 pull ,使用 强制 推送 ,覆盖远程仓库
git push -f
git push -f origin master
A 修改 commit push
B 不pull ,直接强制推送 覆盖远程仓库
A 的 修改丢失
A pull 会冲突
当然 A 也可以修改后 也强制推送
强制推送很危险 ,请谨慎使用
上一篇
下一篇
CFA和CPA
金融行业六大证书介绍
Content-Disposition 响应头的作用
git的各种状态
为啥GO不火
springboot2微服务实例演示