【发布时间】:2022-07-14 23:26:50
【问题描述】:
我试图通过 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。我只有“主”分支。
我运行的命令:
git init
git remote add origin 'pathToMyRepo'
git add -A
git commit -m "first commit"
git push
git push -u origin main
请帮忙。
【问题讨论】: