我试图通过 VSCode 使用 git,但由于不知道如何在 VSCode 上使用 Git,它把一切都搞砸了。
接着我试着像往常一样使用 CMD (Windows)。我正在学习,以前从未见过这种错误,所以不知道该怎么解决。
但当我尝试推送到主分支时,它显示了以下错误:
error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'
我尝试过:
- 我尝试使用另一个分支,那个分支可以正常工作,但是我想使用主分支。
- 我甚至尝试删除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 push some refs to 'myPathToRepo'
这是我的第一次提交:
[master (root-commit) 061a06e] first commit
PS. 我只有'main'分支。
我运行的命令:
git init
git remote add origin 'pathToMyRepo'
git add -A
git commit -m "first commit"
git push
git push -u origin main
请帮忙。