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

2021-04-03  本文已影响0人  祈澈菇凉

使用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,远程仓库同步代码


上一篇下一篇

猜你喜欢

热点阅读