【发布时间】:2020-12-18 10:41:53
【问题描述】:
我使用 git clone 克隆了一个存储库,该存储库依赖于另一个私有存储库。在当前 repo 中,我尝试 go get 那个依赖项 (go get -u ./...),它给我一个错误:
致命:无法读取“https://bitbucket.org”的用户名:终端 提示已禁用
信息
- 我使用
git clone git@my-name.bitbucket.org:company/repo.git将repo 克隆到~/Desktop/BitBucket/Company目录。 - 我有
GOPRIVATE="bitbucket.org/company/*" - 没有
includeIf,一切正常。如果我用 company .gitconfig 替换 .gitconfig 它工作正常。但我需要管理多个帐户... - 命令
git config --get user.name(在repo 内)返回My Name。所以go get有问题
我的 main .gitconfig 文件(在 $HOME 目录中):
[includeIf "gitdir/i:~/Desktop/BitBucket/Company/"]
path = ~/.git/BitBucket/Company/.gitconfig
我的 .gitconfig 文件(用于公司回购 $HOME/.git/BitBucket/Company/.gitconfig):
[user]
name = My Name
email = my.name@company.com
[url "git@my-name.bitbucket.org:"]
insteadOf = https://bitbucket.org/
我的 ssh 配置 文件($HOME/.ssh/config):
Host my-name.bitbucket.org
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/keys/BitBucket/my_name/id_rsa
我的错误是什么?
我还发现了这篇文章:https://medium.com/easyread/today-i-learned-fix-go-get-private-repository-return-error-terminal-prompts-disabled-8c5549d89045。您可以查看第一条评论:
仅供参考,这在使用引用自定义的 .gitconfig 时不起作用 .gitconfig-自定义。它必须存在于 ~/.gitconfig ..... 那是 令人沮丧。
我尝试将 company .gitconfig 移动到主目录(+ 将其重命名为 .gitconfig-company)。没有任何效果。
【问题讨论】:
-
您只想将您的专业帐户用于
bitbucket.org/company/*网址,对吗?您是否尝试仅重写https://bitbucket.org/company/urls ?与git@my-name.bitbucket.org:company/? (注意:我没有测试过,不确定这个 rewting 规则是否有效) -
测试您的设置的一种方法是:运行
git clone https://bitbucket.org/company/repo,看看它是否提示输入密码。您可以打开选项以获得更详细的输出:git clone -v ...,GIT_TRACE=1 git clone ..., ... -
@LeGEC 我试过用这种方式重写 url,但没有解决问题。
标签: git git-config go-get