首页  >  文章  >  后端开发  >  无法读取“https://github.com”的用户名:Windows 上禁用终端提示

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

王林
王林转载
2024-02-10 17:27:08454浏览

无法读取“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删除