如何解决error: failed to push some refs to ‘xxx(远程库)‘(图文解说简洁版)

第一次在上传远程仓库的时候出现此问题:error: failed to push some refs to 'https://gitee.com/zhang-bingqian/crm.git'该怎么解决?


问题

D:\ideaProject\crm\crm>git push -u origin master
To https://gitee.com/zhang-bingqian/crm.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/zhang-bingqian/crm.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.

问题看图欣赏:
在这里插入图片描述

解决方案:

因为问题的可能出现在出现在oschina中的README.md文件不在本地代码目录中,所以我们需要本地也有,不然的话就会冲突。可以解决的方案应该你已经明白了。使用的是直接加入参数-f也可以,但是太过于粗暴,后果可能会什么都同步同步,一般不建议这样。那么最简单的方法如下

1. git pull --rebase origin master
看效果:
在这里插入图片描述

  1. git push -u origin master
    看看是否成功呢?
    在这里插入图片描述
    ok!成功了
posted @   诗风雅韵  阅读(779)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示