【发布时间】:2021-04-12 14:20:04
【问题描述】:
我正在尝试构建一个使用私有 git 存储库的 go 应用程序。我的 github 帐户有一个 ssh 密钥,我的 .gitconfig 文件中有以下内容:
[url "https://username:token@github.com"]
insteadOf = https://github.com
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
当我执行 go test 或 go build 时,我被要求输入密码。然后我得到回复:
go: found github.com/x/businesses in github.com/x/businesses v0.0.0-yy
go: cmd/main/cmd imports
github.com/x/businesses: github.com/x/businesses@v0.0.0-yy/go.mod:
verifying module: github.com/x/businesses@v0.0.0-yy/go.mod:
reading https://sum.golang.org/lookup/github.com/xx/businesses@v0.0.0-yy: 410 Gone
server response:
not found: github.com/x/businesses@v0.0.0-yy:
invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*
in tmp/gopath/pkg/mod/cache/vcs/zz:
exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
我尝试删除 .gitconfig 中的顶部 insteadOf 无缘无故地尝试一些东西。
【问题讨论】:
-
看看
GOPRIVATE。 -
你试过设置 env GIT_TERMINAL_PROMPT=1 吗?
-
另一种选择是添加一个.netrc文件而不是使用insteadOf,这里ec.haxx.se/usingcurl/usingcurl-netrc,文件格式需要给出GitHub.com域名和用户名密码,它适用于我