如何解决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
看效果:
git push -u origin master
看看是否成功呢?
ok!成功了
分类:
java
, git(gitee\github)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具