Git解决push失败

错误信息:

Administrator@YLMF-2019PQDZXZ MINGW64 /f/workspace/demo (master)
$ git push origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': cherispanty
To https://github.com/cherispanty/demo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/cherispanty/demo.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.

可以看到我push到远程仓库失败了,原因是我的这个版本不是服务器上最新的版本,恰巧我本地的代码和远程仓库的代码在同一个文件的同一行做了修改,因此产生了冲突,这是我们应该先使用git pull命令更新最新的代码再上传。
然后我pull一下,发现产生了冲突:
在这里插入图片描述
如何解决?打开冲突的文件,删除不必要的部分(不要乱删别人的代码,最好和别人协商一下),保存退出文件
在这里插入图片描述
这是我的修改:
在这里插入图片描述
再add,commit,push。(注意commit操作不要加文件名)
在这里插入图片描述
最后发现可以push成功了~

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值