我试图通过 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)
我试过:
我在 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'
Run Code Online (Sandbox Code Playgroud)
这是我的第一次提交:
[master (root-commit) 061a06e] first commit
Run Code Online (Sandbox Code Playgroud)
附言。我只有“主”分支。
我运行的命令:
git init
git remote add origin 'pathToMyRepo'
git add -A
git commit -m "first commit"
git push
git push -u origin main
Run Code Online (Sandbox Code Playgroud)
请帮忙。
161*_*903 30
您没有名为 的分支main。你有一个名为 的分支master。
使用正确的名称推送:
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
或者将本地分支名称更改为 main 并使用:
git branch -m main
git push -u origin main
Run Code Online (Sandbox Code Playgroud)
Sky*_*Sky 25
只需确保您的文件夹中有需要提交的内容
| 归档时间: |
|
| 查看次数: |
68331 次 |
| 最近记录: |