前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >git push origin master提交报错解决办法

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

作者头像
王小婷
发布2021-04-09 15:33:59
1.3K0
发布2021-04-09 15:33:59
举报
文章被收录于专栏:编程微刊编程微刊

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

代码语言:javascript
复制
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,但是本地仓库却没有,就可能会出现这种情况。

本地仓库:

远程仓库:

解决办法

代码语言:javascript
复制
git pull origin master --allow-unrelated-histories

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

再次执行 git push origin master

ok,远程仓库同步代码

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档