'Go Get' Private Repo from Bitbucket

梦想与她 提交于 2019-11-27 10:32:06

问题


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'

How can I avoid this occurency? Thank you for reading and have a nice day!


回答1:


go get uses git internally. The following one liners will make git and consequently go get clone your package via SSH.

Github:

git config --global url."git@github.com:".insteadOf "https://github.com/"

BitBucket:

git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"




回答2:


Ammar Bandukwala's answer is correct, but if you find yourself behind a firewall with SSH outgoing port (22) closed, you can use SSH over HTTPS port (443) instead:

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

source: https://confluence.atlassian.com/bitbucket/troubleshoot-ssh-issues-271943403.html#TroubleshootSSHissues-Ifport22isblocked



来源:https://stackoverflow.com/questions/38668444/go-get-private-repo-from-bitbucket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!