error: src refspec main does not match any

实际就是如果把github上文件先下载在本地,在创建git目录,会将分支命名为master,而clone到本地分支会命名为main,这要提交会出错,这时候需要改名。

解决方案A-如果要将分支命名为master

运行git push -u origin master而不是git push -u origin main

或者解决方案B-如果你想把分支命名为main

Run git checkout -B main before git push -u origin main

参考:

https://www.5axxw.com/questions/content/hv0007

这是mastermain争论的一个令人不快的结果。

您的本地GIT客户机创建了一个名为master的默认分支(当您使用git init初始化repo时),但是GitHub上的远程存储库没有master,而默认分支称为main

相关推荐
zh_xuan7 小时前
Android Paging 3实现分页加载
android·git·github·paging 3
johnny23310 小时前
Git进阶:gh、gh-aw、worktree
git
OPHKVPS11 小时前
Anthropic官方Git MCP服务器曝三重漏洞:提示注入即可实现文件读写与远程代码执行
运维·服务器·git
牢七1 天前
无境靶场练习一(失败)
git
HuaCode1 天前
Openclaw一键安装部署(2026年4月最新)
git·python·nodejs·openclaw·api token
小比特_蓝光1 天前
版本控制器Git/调试器gdb/cgdb使用
git
海参崴-1 天前
Git使用完全指南
git
Jp7gnUWcI1 天前
AI Compose Commit:用 AI 智能重构 Git 提交工作流
人工智能·git·重构
小柯博客1 天前
从零开始打造 OpenSTLinux 6.6 Yocto 系统 - STM32MP2(基于STM32CubeMX)(八)
c语言·git·stm32·单片机·嵌入式硬件·嵌入式·yocto
eastyuxiao2 天前
如何在不同的机器上运行多个OpenClaw实例?
人工智能·git·架构·github·php