git使用ssh自动替代https
在使用go mod的时候,并且在一些私有的仓库,例如公司的代码库中,经常会需要输入密码,我们可以现在公司的代码库中设置好ssh密钥
本地执行git命令: 1 2 3 4 5 git config --global url."git@github.com:".insteadOf "https://github.com/" git config --global url."git@git.company.com:".insteadOf "https://git.company.com/" company.com换成你自己公司的地址即可。
而对于 golang.org 上的代码,在这一阶段,会从 https://go.googlesource.com 获取代码,不过庆幸的是,这些代码都在 github 上有镜像,我们可以替换一下: 1 2 3 git config --global url."git@github.com:golang/".insteadOf "https://go.googlesource.com/" ……