首页 > 后端开发 > Golang > 正文

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

王林
发布: 2024-02-10 17:27:08
转载
1283人浏览过

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

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

问题内容

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

server response:
not found: github.com/..../[email&#160;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 进行身份验证。

Media.io AI Image Upscaler
Media.io AI Image Upscaler

Media.io推出的AI图片放大工具

Media.io AI Image Upscaler 62
查看详情 Media.io AI Image Upscaler

并且查看错误消息中提到的文档以了解其他选项

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中文网其它相关文章!

相关标签:
Github
Github

Github是一款非常实用的代码开放工具,用户可以按照自己的需求进行搜索,从而快速定位到所需的代码或项目位置,还能在软件中建立自己的代码仓库,有需要的小伙伴快来保存下载体验吧!

下载
来源:stackoverflow网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号