Github error: src refspec main does not match any



我试着按照说明做一个提交到github,但它立即坏了

D:Workhtdocstemp>git add *
warning: LF will be replaced by CRLF in .htaccess.
The file will have its original line endings in your working directory
D:Workhtdocstemp>git commit -m "first commit"
[master 2f28669] first commit
1 file changed, 6 insertions(+)
create mode 100644 .htaccess
D:WorkVikasSitehtdocstemp>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

然后我意识到默认情况下Github的master分支被重命名为main,所以我又尝试了同样的事情

D:Workhtdocstemp>git push origin --delete master
To https://github.com/*******/php_social_network.git
- [deleted]         master
D:Workhtdocstemp>git commit -m "test"
[master *****] test
2 files changed, 39 insertions(+)
create mode 100644 github
create mode 100644 github.pub
D:Workhtdocstemp>git push --set-upstream origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/******/php_social_network.git'

我在这里做错了什么,我怎么能推到main分支代替?

您可能需要先将本地分支主机重命名为main:

git branch -m master main
git push -u origin main

git push origin --delete master确实删除了远程origin/master分支。

git statusgit branch -avv检查当前分支

相关内容

最新更新