git - 去使用 ssh 而不是 https(不在 github 上)
问题描述
我们有一个只能通过 ssh/git(没有 https)访问的私有代码存储库,我们希望在那里托管我们的 go 代码/模块。
首先我试过:
git config --global url."git@code.internal.local:".insteadOf "https://code.internal.local/"
所以,以下两项工作都很好:
git clone git@code.internal.local:reponame.git
git clone https://code.internal.local/reponame
但是go get code.internal.local/reponame
失败了,因为 go 仍然坚持尝试 https://... 而不是 git。
package code.internal.local/reponame: unrecognized import path "code.internal.local/reponame": https fetch: Get "https://code.internal.local/reponame?go-get=1": dial tcp 192.168.0.5:443: i/o timeout
解决方案
我检查了我的.gitconfig并找到了这个(对于github私人仓库) -
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
上面的配置对我有用。您也可以尝试在项目根目录中创建一个.netrc文件,但不应将其推送到远程代码仓库。
推荐阅读
- typescript - 打字稿:在接口中使用枚举值
- python - 以下代码在python(蝗虫代码片段)中意味着什么?
- javascript - AngularJS 应用程序:无法更新 $index
- regex - 需要正则表达式的帮助
- spring - NoSuchBeanDefinitionException:没有“java.util.function.Function”类型的限定 bean
' - json - AngularJS - 过滤掉下拉列表中的值
- r - 如何按天合并上一行和下一行
- android - 谷歌地图从 url 更新集群标记图标
- oracle12c - 如何在 sql*loader 控制文件中写入多个 CONTINUEIF 条件?
- scala - org.mockito.exceptions.misusing.WrongTypeOfReturnValue:在单元测试用例上