我在將更改從 Visual Studio 代碼推送到 Github 時遇到了困難。對于背景關系,我對 git 和 github 比較陌生——在瀏覽了過去的 SO 討論和其他在線論壇后,并嘗試了以下操作:使用 git init/git remote origin 將本地計算機與 github 連接,以及生成 SSH 密鑰.
然而,這些東西似乎都不起作用。當我輸入
git push -u origin master
終端以 回應error: src refspec master does not match any。
此外,我不確定這是否相關,但是當我輸入時
~/.ssh/config
終端回應 the term '~/.ssh/config' is not recognized as the name of a cmdlet, function, script file, or operable program.
任何有關故障排除的想法將不勝感激。感謝大家!
uj5u.com熱心網友回復:
error: src refspec master does not match any表示本地存盤庫沒有名為 master 的分支。它可以是main或其他名稱。運行git branch以列出本地分支。當前簽出*的名稱前有一個。
至于第二個錯誤,當您輸入時~/.ssh/config,它會嘗試執行此檔案。但該檔案不可執行(也不應該是),并且它不是 cmdlet、函式、腳本檔案或可運行的程式。
第一個錯誤與~/.ssh/config.
uj5u.com熱心網友回復:
當我運行“
git push origin main”時,終端給了我ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository.
這取決于您的背景關系,但在我的公司環境中,SSH 已關閉以進行傳出查詢。
這意味著我必須使用 HTTPS URL(在創建個人訪問令牌后,用作密碼)
cd /path/to/local/repository
# if you had already defined "origin"
git remote set-url origin https://github.com/me/MyNewRepo
不要忘記首先在 GitHub 上創建一個空的“myNewRepo”存盤庫。
您可以直接從您的作業站執行此操作。
安裝 GitHub CLIgh,然后:
cd /path/to/local/repository
gh repo create myNewRepo --source=.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/398247.html
