从私有 git 仓库获取失败,原因是 URL 中包含了 .git。

huangapple go评论92阅读模式
英文:

Go get from private git repository fails due to .git in url

问题

在使用github.com时,用于浏览存储库的URL不包含.git扩展名:

但是,“使用https克隆”URL包含.git

你可以这样获取它:

go get github.com/someuser/helloworld

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

  • helloworld.git

但是,用于浏览存储库的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的行为不同?

英文:

When using github.com, the url used to browse to a repo does not contain the .git extension:

but the "clone with https" url does:

And you go get it like this:

go get github.com/someuser/helloworld

In our private git repo, we create bare repos in a directory ending in .git (based on convention):

  • helloworld.git

But the url (served using https://github.com/klaussilveira/gitlist) to browse to the repo also contains .git:

This causes go get to fail because it doesn't expect the .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

Leaving off the .git part also fails:

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 ())

Renaming the bare repo to just helloworld solves the problem. But this isn't the convention.

What am I missing? Is there a server setting we are missing so that we can leave off the .git extension when browsing? Should we just just leave off .git when naming the bare repo? Why does github.com have different behavior?

答案1

得分: 1

在仓库服务器上,对每个仓库使用软链接。所以在这种情况下,只需执行以下命令:

ln -s helloworld.git helloworld

根据重命名成功的事实,它应该可以正常工作。

嗯,如果是Windows服务器...我相信你可以通过谷歌找到创建软链接(有时称为符号链接)的方法。

英文:

On the repo server, use a soft link along side each of the repos. So in this case, just do a

ln -s helloworld.git helloworld

and it should work based on the fact that the rename worked.

Um, if it's a Windows server... I'm sure you can google a way to create a soft link, sometimes called a symlink.

huangapple
  • 本文由 发表于 2017年3月31日 00:38:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/43123664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定