卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章35249本站已运行394

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

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

php小编香蕉在使用Windows系统时,有时会遇到一个问题:“无法读取https://github.com的用户名:Windows上禁用终端提示”。这个问题常常让人感到困惑,因为在使用Git时,终端提示是非常重要的一个功能。本文将向大家介绍如何解决这个问题,让我们能够正常地使用终端提示功能。接下来,让我们一起来看看具体的解决方法吧!

问题内容

我试图使用 go get -u 从私有存储库中获取一些依赖项,但它一直失败并出现以下错误:

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://[email protected]/"]
    insteadOf = https://github.com/
卓越飞翔博客
上一篇: 从 Go 打开 pfring:pfring NewRing 错误:没有这样的设备
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏