【问题标题】:Receiving fatal: could not read Username for 'https://github.com': terminal prompts disabled while building project in terminal收到致命错误:无法读取“https://github.com”的用户名:在终端中构建项目时终端提示已禁用
【发布时间】:2020-05-04 22:14:55
【问题描述】:

我已经开始从事 Golang 项目。使用 make 构建时,出现以下错误:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

为了解决这个问题,我在浏览过类似的帖子go get results in 'terminal prompts disabled' error for github private repo 后做了以下工作:

export GIT_TERMINAL_PROMPT=1

但这并没有解决问题,现在它似乎在无限循环询问用户名和密码。

我的 git 配置如下:

$git config --list

remote.origin.url=git@github.com:GolangProjects/Project1.git

即使在这个配置之后,为什么它继续使用 https 而不是 SSH,没有得到任何线索。请帮忙。

【问题讨论】:

  • 您的 Makefile 是否包含对 git 的任何调用或任何可能使用它的程序,例如包管理器?你的项目中有子模块吗?
  • 是的,作为构建的一部分,它会拉取并安装 go 依赖项。
  • 考虑提供minimal reproducible example。你从你的 Makefile 运行什么命令?

标签: git


【解决方案1】:

改为创建一个 SSH 密钥并将其用作 git repo 的默认登录方法。 您可以按照此链接在您的机器上创建一个用于身份验证的 ssh 密钥:

Generating a new SSH key and adding it to the ssh-agent

然后使用它来默认您的登录方法使用 ssh 密钥而不是您的凭据:

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

【讨论】:

  • 对 Mac/iOS 开发者的警告 - 上面的全局 git 配置将修复命令行上的问题,但会破坏 Xcode 中的 Git。
【解决方案2】:

git fetch 有同样的问题:

https://github.com/andry81-devops/github-accum-stats/runs/4429723185?check_suite_focus=true#step:2:169

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/master*:refs/remotes/origin/master* +refs/tags/master*:refs/tags/master*
  Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
  The process '/usr/bin/git' failed with exit code 128
  Waiting 14 seconds before trying again

要解决这个问题,您必须更新 repo secrets 令牌。

【讨论】:

    猜你喜欢
    • 2023-02-07
    • 2020-08-02
    • 2017-08-12
    • 2019-08-29
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 2021-03-09
    相关资源
    最近更新 更多