前置条件私库需要给你账号权限,可拉取的权限,否则无法进行正常拉取
我们采用ssh方式,需要在本地生成对应的 rsa 的公钥和私钥,将公钥配置如下图:
Host bitbucket.org
Hostname bitbucket.org
User git
IdentityFile ~/.ssh/你的私钥
[url "ssh://git@bitbucket.org/"]
insteadOf = https://bitbucket.org/
因为 go mod 和 go get 默认走 https 形式拉取,所有需要替换 git 的拉取方式为 ssh
当然也可以执行命令:
git config --global --add url."https://bitbucket.org/".insteadOf "ssh://git@bitbucket.org/"