gpt4 book ai didi

git - 由于 url 中的 .git,从私有(private) git 存储库获取失败

转载 作者:IT王子 更新时间:2023-10-29 02:12:12 25 4
gpt4 key购买 nike

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

但是“使用 https 克隆”url 会:

然后你像这样得到它:

去获取 github.com/someuser/helloworld

在我们的私有(private) 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 有不同的行为?

最佳答案

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

ln -s helloworld.git helloworld

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

嗯,如果它是 Windows 服务器...我相信您可以通过谷歌搜索创建软链接(soft link)的方法,有时称为符号链接(symbolic link)。

关于git - 由于 url 中的 .git,从私有(private) git 存储库获取失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43123664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com