error: src refspec master does not match any

新项目 push 至 github 仓库的时候抛出了如下异常

复制代码
error: src refspec master does not match any

解决办法

首先,查看当前 branch, 因新项目只有一个 main

复制代码
git branch

早期都是 master 而不是 main,所以将现有的改成 main 或者 master 均可

复制代码
git branch -m main // 或者 git branch -m master

最后,重新尝试 push, 此处改成 main 变 origin main 反之是 master

复制代码
git push -u origin main // 或者 git push -u origin master

以上便是此次分享的全部内容,希望能对大家有所帮助!

相关推荐
崔庆才丨静觅6 小时前
Claude Code GitHub Actions 使用教程
github·api·claude
砖厂小工1 天前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
程序员鱼皮1 天前
又一个新项目完结,我要出海了!
ai·github·开源项目
徐小夕1 天前
pxcharts-vue:一款专为 Vue3 打造的开源多维表格解决方案
前端·vue.js·github
Moment1 天前
想要长期陪伴你的助理?先从部署一个 OpenClaw 开始 😍😍😍
前端·后端·github
我叫黑大帅1 天前
前端如何利用 GitHub Actions 自动构建并发布到 GitHub Pages?
前端·面试·github
HelloGitHub1 天前
这个年轻的开源项目,想让每个人都能拥有自己的专业级 AI 智能体
开源·github·agent
刘发财2 天前
弃用html2pdf.js,这个html转pdf方案能力是它的几十倍
前端·javascript·github