小编She*_*eeb的帖子

使用 ssh 而不是 https(不在 github 上)

我们有一个只能通过 ssh/git (无 https)访问的私有代码存储库,并且我们希望在那里托管我们的 go 代码/模块。

首先我尝试:

git config --global url."git@code.internal.local:".insteadOf "https://code.internal.local/"
Run Code Online (Sandbox Code Playgroud)

因此,以下两项都可以正常工作:

  • 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
Run Code Online (Sandbox Code Playgroud)

git go go-modules

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

git ×1

go ×1

go-modules ×1