【问题标题】:Go get from private git repository fails due to .git in url由于 .git 在 url 中,从私有 git 存储库获取失败
【发布时间】:2017-03-30 16:38:02
【问题描述】:

使用 github.com 时,用于浏览 repo 的 url 不包含 .git 扩展名:

但“使用 https 克隆”网址可以:

然后你就这样得到它:

go get github.com/someuser/helloworld

在我们的私有 git 仓库中,我们在以 .git 结尾的目录中创建裸仓库(根据约定):

  • helloworld.git

但是浏览到 repo 的 url(使用 https://github.com/klaussilveira/gitlist 提供)也包含 .git:

这会导致 go get 失败,因为它不期望 .git:

C:\>go get -u -f -insecure git.test.net/helloworld.git
# cd .; git clone git.test.net/helloworld   C:\Temp\golang\src\git.test.net\helloworld.git
fatal: repository 'git.test.net/helloworld' does not exist
package git.test.net/helloworld.git: exit status 128

离开 .git 部分也会失败:

C:\>go get -u -f -insecure git.test.net/helloworld
    package git.test.net/helloworld: unrecognized import path "git.test.net/helloworld" (parse https://git.test.net/helloworld?go-get=1: no go-impor
    t meta tags ())

将裸仓库重命名为 helloworld 即可解决问题。但这不是惯例。

我错过了什么?我们是否缺少服务器设置,以便我们在浏览时可以省略 .git 扩展名?在命名裸仓库时,我们是否应该省略 .git?为什么 github.com 有不同的行为?

【问题讨论】:

    标签: git github go


    【解决方案1】:

    在 repo 服务器上,使用每个 repos 旁边的软链接。所以在这种情况下,只需做一个

    ln -s helloworld.git helloworld
    

    它应该基于重命名有效的事实。

    嗯,如果它是 Windows 服务器...我相信您可以通过 Google 搜索一种创建软链接的方法,有时称为符号链接。

    【讨论】:

    • 感谢这工作。 Repos 在 GitList 中出现了两次,但可以忍受。
    猜你喜欢
    • 1970-01-01
    • 2019-05-29
    • 2018-12-15
    • 2020-06-29
    • 2022-09-28
    • 2021-11-15
    • 2019-08-30
    • 2021-02-04
    • 1970-01-01
    相关资源
    最近更新 更多