git 来自 Bitbucket 的“Go Get”私人回购
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38668444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Go Get' Private Repo from Bitbucket
提问by BeeAdmin
So basically, I have an Openshift Project that on Git push, downloads all libraries with 'Go get' and builds the project on-the-fly and so, I have some code I don't want people to see from my own library, and for it to compile properly, the code needs to be taken from github.com or another repo, so I created a private bitbucket.org repo, now, as a public repo it works fine, but when I try to 'Go Get' from my private repo, it gives me 'Forbidden 403'
所以基本上,我有一个 Openshift 项目,它在 Git push 上使用“Go get”下载所有库并即时构建项目,因此,我有一些代码我不希望人们从我自己的库中看到,为了使其正确编译,代码需要从 github.com 或其他存储库中获取,因此我创建了一个私有的 bitbucket.org 存储库,现在作为公共存储库它工作正常,但是当我尝试“Go Get”时从我的私人仓库中,它给了我“禁止 403”
How can I avoid this occurency? Thank you for reading and have a nice day!
我怎样才能避免这种情况发生?感谢您的阅读,祝您有美好的一天!
回答by Ammar Bandukwala
go get
uses git
internally. The following one liners will make git
and consequently go get
clone your package via SSH.
go get
git
内部使用。下面的一个衬垫将通过 SSH制作git
并因此go get
克隆您的包。
Github:
GitHub:
git config --global url."[email protected]:".insteadOf "https://github.com/"
git config --global url."[email protected]:".insteadOf "https://github.com/"
BitBucket:
比特桶:
git config --global url."[email protected]:".insteadOf "https://bitbucket.org/"
git config --global url."[email protected]:".insteadOf "https://bitbucket.org/"
回答by vin047
Ammar Bandukwala's answeris correct, but if you find yourself behind a firewall with SSH outgoing port (22) closed, you can use SSH over HTTPS port (443) instead:
Ammar Bandukwala 的回答是正确的,但如果您发现自己在防火墙后面,并且 SSH 出站端口 (22) 关闭,您可以使用 SSH over HTTPS 端口 (443) 代替:
git config --global url."ssh://[email protected]:443/<account_name>".insteadOf "https://bitbucket.org/<account_name>"
来源:https: //confluence.atlassian.com/bitbucket/troubleshoot-ssh-issues-271943403.html#TroubleshootSSHissues-Ifport22isblocked