git - 使用两个不同的 bitbucket 帐户从 bitbucket 'go get'

标签 git go ssh bitbucket go-get

#1 我遵循了一些关于如何使用两个不同的 ssh key 访问 github 或 bitbucket 的文章,当我执行 git clone ... 时它工作正常。 。所以,我可以做一个git clone git://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31565845715658455944531f525e5c" rel="noreferrer noopener nofollow">[email protected]</a>/...git clone git://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ccaba5b88ca1b5afa3a1bcada2b5e1aea5b8aeb9afa7a9b8e2a3beab" rel="noreferrer noopener nofollow">[email protected]</a>/...没有任何问题。

#2 我还关注了一些关于如何使用私有(private)存储库的文章

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

最佳答案

谢谢大家的回复。经过一些测试和修补后,我发现了这个明确的步骤:

在 ~/.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 [email protected]//”并使用自定义 ssh key

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

并执行:

git config --global url."ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8fe8e6fbcfeee3fbfcfce7a1f8e0fde4a2ede6fbedfaece4eafba1e0fde8" rel="noreferrer noopener nofollow">[email protected]</a>:443/<account_name>".insteadOf "https://bitbucket.org/<account_name>"

关于“工作”前缀的注意事项

关于git - 使用两个不同的 bitbucket 帐户从 bitbucket 'go get',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68254076/

相关文章:

git - 如何在 git/macbook 中将 VScode 设置为核心编辑器

git - 无法符号链接(symbolic link) share/git-core/contrib/usr/local/share/git-core 不可写

git - 如何在没有 checkout 的情况下 git 丢弃分支?

git - 我如何在远程 Hook git pull?

go - 如何为网络包设置 DNS 缓存?

go - 代表许多领域的最优雅的方式

google-app-engine - GOLANG HTTP Basic-Auth with Google App Engine URLFetch

linux - Centos 6.4 Nodejs 外部没有响应

windows - 在 Windows 上使用 Cygwin 的 SSH ControlMaster 真的可行吗?

go - 无法通过远程ssh命令在远程服务器上构建go程序