首頁  >  文章  >  後端開發  >  無法讀取「https://github.com」的使用者名稱:Windows 上停用終端提示

無法讀取「https://github.com」的使用者名稱:Windows 上停用終端提示

王林
王林轉載
2024-02-10 17:27:08455瀏覽

无法读取“https://github.com”的用户名:Windows 上禁用终端提示

php小編香蕉在使用Windows系統時,有時會遇到一個問題:“無法讀取https://github.com的使用者名稱:Windows上停用終端提示” 。這個問題常常讓人感到困惑,因為使用Git時,終端提示是非常重要的功能。本文將向大家介紹如何解決這個問題,讓我們能夠正常地使用終端機提示功能。接下來,讓我們一起來看看具體的解決方法吧!

問題內容

我試圖使用go get -u 9970c58ef086b1aaf39ae0e8d5f51c3e 從私人儲存庫中取得一些依賴項,但它一直失敗並出現以下錯誤:

server response:
not found: github.com/..../[email protected]: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/168bff8af96cdfac9cbe3ad64f7753732f8a19d99f7f1e897f19371e1ea453d9: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

我嘗試匯出 set git_terminal_prompt=1 但沒有任何反應,發出相同的錯誤。對於 go 1.13,有什麼辦法 go get 會在 windows 上忽略此變數的值嗎?

解決方法

嘗試為 github 設定臨時憑證處理程序:

git_user="your-github-username-or-email"
git_pass="pat"

git config --global credential.helper "!f() { echo \`"username=`${git_user}`npassword=`${git_pass}\`"; }; f"

或安裝 github cli 並使用 gh auth login 對 github 進行驗證。

並且查看錯誤訊息中提到的文件以了解其他選項

git 可以設定為透過 https 進行身份驗證或使用 ssh 取代 https。若要透過 https 進行身份驗證,您可以在 git 查閱的 $home/.netrc 檔案中新增一行:

machine github.com login username password apikey

對於 github 帳戶,密碼可以是個人存取權杖。

git 也可以配置為使用 ssh 取代 https 來處理與給定前綴相符的 url。例如,要使用 ssh 進行所有 github 訪問,請將這些行新增至 ~/.gitconfig

[url "ssh://<a href="https://www.php.cn/link/89fee0513b6668e555959f5dc23238e9" class="__cf_email__" data-cfemail="3d5a54497d5a544955485f135e5250">[email&#160;protected]</a>/"]
    insteadOf = https://github.com/

以上是無法讀取「https://github.com」的使用者名稱:Windows 上停用終端提示的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:stackoverflow.com。如有侵權,請聯絡admin@php.cn刪除