#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]/
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/