dpqmu84646
2017-03-30 16:38
浏览 168

由于url中的.git,无法从私有git存储库获取数据

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条回答 默认 最新

  • dongxin1980 2017-03-30 16:56
    已采纳

    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.

    已采纳该答案
    打赏 评论