当前位置:   article > 正文

Git push 报错: Updates were rejected because the remote contains work that you do not have locally._hint: updates were rejected because the remote con

hint: updates were rejected because the remote contains work that you do not

问题描述

再推送 GitHub 仓库时,出现下面的错误

$ git push origin master
To http://xxxxxx/test.git
 ! [rejected]        master -> master(fetch first)
error: failed to push some refs to 'http://xxxxxx/Android.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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

问题根源

由于你在别的地方(例如新的服务器)提交了另外一份代码,导致GitHub网址上的代码和本地的代码并不一致。所以需要我们先在本地上 pull GitHub上的代码,在本地解决冲突,然后 push 到GitHub上即可。

解决方案

git pull origin
git push origin master
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/685150
推荐阅读
相关标签
  

闽ICP备14008679号