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

推送到远程仓库

git push -u origin master

出现如下错误

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:qiyuebuku/WxRobot.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 origin master 

git push -u origin master //把本地仓库的文件推送到远程仓库wen

  

问题解决

原文地址:https://www.cnblogs.com/qybk/p/10880901.html