git push origin master提交报错解决办法

使用git push origin master将本地提交推送到远程仓库的时候
遇到了这样的一个报错

wangting@DESKTOP-O81VEVO MINGW64 ~/Desktop/wisdom_inventory_admin (master)
$ git push origin master
To https://gitee.com/wangyoko/wisdom_inventory_admin.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/wangyoko/wisdom_inventory_admin.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.

原因是远程仓库中的文件和我们本地的仓库有差异,例如你的远程仓库有个文件Readme. md,但是本地仓库却没有,就可能会出现这种情况。

本地仓库:


远程仓库:


解决办法

git pull origin master --allow-unrelated-histories

将远程仓库的Readme. md一起拉下来同步到本地

再次执行
git push origin master


ok,远程仓库同步代码


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章