【问题标题】:Github error: src refspec main does not match anyGithub 错误:src refspec main 不匹配任何
【发布时间】:2022-12-06 02:54:17
【问题描述】:

我试图按照说明对 github 进行提交,但它立即崩溃了

D:\Work\htdocs\temp>git add *
warning: LF will be replaced by CRLF in .htaccess.
The file will have its original line endings in your working directory\

D:\Work\htdocs\temp>git commit -m "first commit"
[master 2f28669] first commit
 1 file changed, 6 insertions(+)
 create mode 100644 .htaccess

D:\Work\VikasSite\htdocs\temp>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:\Work\htdocs\temp>git push origin --delete master
To https://github.com/*******/php_social_network.git
 - [deleted]         master

D:\Work\htdocs\temp>git commit -m "test"
[master *****] test
 2 files changed, 39 insertions(+)
 create mode 100644 github
 create mode 100644 github.pub

D:\Work\htdocs\temp>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 分支?

【问题讨论】:

    标签: git github


    【解决方案1】:

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

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

    git push origin --delete master确实删除了偏僻的origin/master分支。

    使用git statusgit branch -avv检查当前分支。

    【讨论】:

      猜你喜欢
      • 2022-07-14
      • 2013-03-28
      • 2017-03-05
      • 2014-02-11
      • 1970-01-01
      • 2023-01-30
      • 2014-12-29
      • 2012-05-21
      相关资源
      最近更新 更多