【问题标题】:Error failed to push some refs to git commit错误未能将一些参考推送到 git commit
【发布时间】:2022-01-25 17:46:27
【问题描述】:

我正在尝试将导航栏文件上传到 git,但它一直说无法推送某些引用,我不知道我哪里出错了。

PS E:\navbar> git init
Initialized empty Git repository in E:/navbar/.git/
PS E:\navbar> git add README.md
fatal: pathspec 'README.md' did not match any files
PS E:\navbar> git commit -m "first commit"
Author identity unknown

*** Please tell me who you are.


to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '신은영@DESKTOP-0T69V65.(no
PS E:\navbar> git remote add origin https://github.com/kimdohyeon0811/learnit
PS E:\navbar> git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learnit'
PS E:\navbar> git remote -v
origin  https://github.com/kimdohyeon0811/learn_css.git (fetch)
origin  https://github.com/kimdohyeon0811/learn_css.git (push)
PS E:\navbar> git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learn_css.git'
PS E:\navbar>

【问题讨论】:

    标签: github


    【解决方案1】:

    这里有两个不同的问题,它们是相关的。首先是您未能配置提交中使用的姓名和电子邮件,因此 Git 拒绝提交任何更改。第二个是因为您的存储库中没有提交,所以尝试推送分支mainmaster 不起作用,因为它不存在。这就是当您看到“src refspec...does not match any”时收到的消息。

    您需要配置您的姓名和电子邮件,它们存储在user.nameuser.email中。请注意,user.name 是个人名称,而不是用户名。因此,例如,有人可能会运行这些命令:

    $ git config --global user.name "Pat Doe"
    $ git config --global user.email pdoe@example.com
    

    然后,一旦您进行了这些更改,您就可以提交并且它应该会成功。提交后,您可以推送它们。

    请注意,如果您想使用main 作为默认分支,但您的存储库使用master,您可以运行git branch -m main,这将重命名分支。如果您想这样做,请在推送之前进行。

    【讨论】:

      猜你喜欢
      • 2021-08-07
      • 1970-01-01
      • 2012-08-16
      • 2018-03-27
      • 2012-04-05
      • 2012-04-07
      • 2020-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多