【问题标题】:'go get' from bitbucket with two different bitbucket account使用两个不同的 bitbucket 帐户从 bitbucket 中“获取”
【发布时间】:2021-07-08 18:59:00
【问题描述】:

#1 我关注了一些关于如何使用两个不同的 ssh 密钥访问 github 或 bitbucket 的文章,当我执行 git clone ... 时它工作正常。所以,我可以毫无问题地进行git clone git://git@github.com/...git clone git://git@mycompany-bitbucket.org/...

#2 我还关注了一些关于如何使用私有仓库的文章

但是,如果我将两篇文章(#1 和 #2)结合起来,go get ... 将始终使用 https://api.bitbucket.org/2.0/repositories/...。那么,有没有办法强制go get ... 使用https://api.mycompany-bitbucket.org/2.0/repositories/ 之类的东西?

【问题讨论】:

标签: git go ssh bitbucket go-get


【解决方案1】:

感谢大家的回复。在做了一些测试和修改后,我发现了这个确定的步骤:

在 ~/.ssh/config:

# Work Bitbucket account
Host work-bitbucket.org
 HostName bitbucket.org
 User git
 AddKeysToAgent yes
 IdentityFile ~/.ssh/id_dsa-work

# Work Bitbucket account
Host altssh.work-bitbucket.org
 HostName altssh.bitbucket.org
 User git
 AddKeysToAgent yes
 IdentityFile ~/.ssh/id_dsa-work

work-bitbucket.org 允许您执行“git clone git@work-bitbucket.org//”并使用自定义 ssh 密钥

altssh.work-bitbucket.org 满足go get ... 的要求(与export GOPRIVATE=bitbucket.org/<account_name>

同时执行:

git config --global url."ssh://git@altssh.work-bitbucket.org:443/<account_name>".insteadOf "https://bitbucket.org/<account_name>"

注意“工作”前缀

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-21
    • 2016-03-28
    相关资源
    最近更新 更多