小编nav*_*een的帖子

git:错误:src refspec main 与任何内容都不匹配

我试图通过 VSCode 使用 git,因为我不知道如何在 VSCode 上使用 Git,所以一切都搞砸了。
然后我尝试像往常一样使用CMD(Windows)。我正在学习,以前从未见过这种错误,所以我不知道如何解决这个问题。

但当我尝试推送到主分支时,它显示了这些错误:

error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'
Run Code Online (Sandbox Code Playgroud)

我试过:

  • 我尝试使用另一个分支,它工作正常,但我想使用主分支
  • 我什至尝试删除 git 文件夹并再次启动它

我在 StackOverflow 上看到过其他帖子,大多数都说“先提交然后推送,因为当您在未提交的情况下推送时会出现此错误”。

删除.git/文件夹并重新启动后,它开始显示相同的错误

>git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

>git push -u origin main
error: src refspec main does not match any
error: failed to …
Run Code Online (Sandbox Code Playgroud)

git github

27
推荐指数
3
解决办法
7万
查看次数

标签 统计

git ×1

github ×1