步骤
1:GOPRIVATE
环境变量来配置私有仓库。
$ go env -w GOPRIVATE=gitlab.com/xxx
2. 配置ssh 配置
# 分别生成ssh key ssh-keygen -t rsa -C "your_email@example.com"
# vi ~/.ssh/config 追加 Host igitlab Hostname igitlab.xxx.com User zhangjc17 IdentityFile ~/.ssh/id_rsa
3. 配置替换url -- 原本是https的需要更改为ssh。 注意前缀有ssh://
git config --global url."ssh://git@igitlab.xxx.com".insteadOf "https://igitlab.xxx.com"