Src refspec main does not match any
大约 1 分钟使用指南页面配置使用指南
问题表现
我们向github推送本地有现有项目的时候, 如果提示出现以下这个异常, 是提示你没有任何代码需要提交.
error: src refspec main does not match any
error: failed to push some refs to 'github.com:username/xxxx.git'
解决方案
我们先执行 git status
, 如果提醒以下这种 Untracked files 信息
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.github/
.gitignore
deploy.sh
xxxxx/
package.json
pnpm-lock.yaml
就是提示 没有暂存文件, 也没有填写提交说明。
这是我们可以执行以下这个命令即可。
git add . # 将当前修改过的文件添加到暂存区
git commit -m '提交说明' # 将修改的文件提交到本地仓库
git push # 推送到服务端. 也可能会提示要执行下面的命令
git push --set-upstream origin main # main是分支名称,看自己的情况命名。
希望对你有帮助。