我正在嘗試將導航欄檔案上傳到 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>
uj5u.com熱心網友回復:
你在這里有兩個不同的問題,它們是相關的。首先是你沒有配置你提交中使用的姓名和電子郵件,所以 Git 拒絕提交任何更改。第二個是因為您的存盤庫中沒有提交,嘗試推送分支main或master不起作用,因為它不存在。這就是當您看到“src refspec...不匹配任何”時收到的訊息。
您需要配置您的姓名和電子郵件,它們存盤在user.name和 中user.email。請注意,這user.name是個人名稱,而不是用戶名。因此,例如,有人可能會運行這些命令:
$ git config --global user.name "Pat Doe"
$ git config --global user.email [email protected]
然后,一旦您進行了這些更改,您就可以提交并且它應該會成功。一旦你有提交,你就可以推送它們。
請注意,如果您想main用作默認分支但您的存盤庫正在使用master,您可以運行git branch -m main并重命名分支。如果您想這樣做,請在推動之前進行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/395065.html
標籤:github
