【github小问题】——push后报错error: src refspec master does not match any

温馨提示:这个问题可能有多种问题导致如未commit,本文在此讲述的是我遇到的这一种情况。

一、问题描述

从本地上传文件至github仓库时,add和commit都执行了且成功,但是执行git push -u origin master后出现了:error: src refspec master does not match any的报错。

二、问题原因以及解决方法

网上有很多问题原因的解决和描述,但我所遇到的这个问题是通过询问gpt后解决的。

GPT说:这个报错通常是由于GitHub仓库的默认分支名称发生了变化造成的。过去,Git 的默认分支是 master,但现在许多项目和托管服务(包括 GitHub)将默认分支名称改为了 main

然后我去看了一眼我的github仓库,果然是main。

解决方法:把push指令改为git push -u origin main

(即把master改成main)就可以成功解决了!

希望可以帮助到大家~

相关推荐
小弥儿6 小时前
GitHub今日热榜 | 2026-08-16:大模型微调与编码工具扎堆
学习·开源·github
starp11 小时前
skill 管理,后缀为public可以被git commit
github
315356691311 小时前
DeepSeek Harness 发布后,我没急着跑 Demo,先把 `.agents/` 翻了一遍
前端·后端·github
u13013014 小时前
GitHub 热榜项目:周榜(2026-08-16)
github
暮云星影15 小时前
git版本发布
git·gitee·github·gitea
m4Rk_15 小时前
【论文阅读】Agent 记忆机制(41):Agentic Plan Caching——将历史执行轨迹转化为可复用的计划记忆
论文阅读·人工智能·学习·开源·github
本地化文档15 小时前
poethepoet-docs-l10n
python·github·gitcode·sphinx
晴天小庭16 小时前
DeepSeek Harness纯净桌面版(基于Tauri)开源,欢迎品鉴
github
苏灿烤鱼17 小时前
一套进程代替八件套,桌面更稳还是单点更大
linux·github·shell