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

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

相关推荐
四问四不知1 小时前
github上的几个热门项目
github
CoderJia程序员甲2 小时前
GitHub 热榜项目 - 日榜(2025-12-3)
ai·开源·llm·github·ai教程
Hotakus8 小时前
手柄也能辅助绘画与办公 XialloControl 新的手柄映射键鼠软件
windows·开源·github·开源软件·个人开发
阿里嘎多学长9 小时前
2025-12-05 GitHub 热点项目精选
开发语言·程序员·github·代码托管
CoderJia程序员甲12 小时前
GitHub 热榜项目 - 日榜(2025-12-5)
ai·开源·大模型·github·ai教程
知行力13 小时前
【GitHub每日速递 20251205】ByteDance开源verl:灵活高效的大语言模型RL训练库,解锁多项前沿技术!
语言模型·开源·github
sijiaoh13 小时前
用Renovate处理Private Submodules
ci/cd·github
小年糕是糕手13 小时前
【C++】类和对象(六) -- 友元、内部类、匿名对象、对象拷贝时的编译器优化
开发语言·c++·算法·pdf·github·排序算法
dragoooon3415 小时前
[Linux网络基础——Lesson9.「TCP 全连接队列与 tcpdump 抓包」]
前端·git·github