错误信息:

[email protected] 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一下,发现产生了冲突:
Git解决push失败
如何解决?打开冲突的文件,删除不必要的部分(不要乱删别人的代码,最好和别人协商一下),保存退出文件
Git解决push失败
这是我的修改:
Git解决push失败
再add,commit,push。(注意commit操作不要加文件名)
Git解决push失败
最后发现可以push成功了~

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-12-11
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-06-12
相关资源
相似解决方案