为什么 git submodule update 失败?

8
我有以下的 .gitmodules 文件:
[submodule "web/blog"]
    path = web/blog
    url = git://amygdala.servebeer.com:lucky_blog.git

[submodule "web/old"]
    path = web/old
    url = git://amygdala.servebeer.com:old_lucky.git

当我克隆仓库并运行git submodule init && git submodule update(或git submodule init --update)时,我会出现以下错误:
Cloning into web/blog...
fatal: Unable to look up  (port 9418) (Name or service not known)
Clone of 'git://amygdala.servebeer.com:lucky_blog.git' into submodule path 'web/blog' failed

我注意到三件事情引起了一些担忧:
  1. 第二个 .gitmodules 条目(web/old)被克隆得很好,没有任何问题。
  2. 错误消息中似乎有一个额外的空格,在这里我认为 git 通常会列出它无法查找的主机名(在上面列出的错误之前列出端口号列表)。
  3. git clone git://amygdala.servebeer.com:lucky_blog.git 运行得非常好。
这个仓库有什么问题?这是 git 的错误还是我在设置仓库时搞错了什么?
编辑:下面是我的 git 配置供参考:
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@amygdala.servebeer.com:luckybead.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[submodule "web/blog"]
    url = git://amygdala.servebeer.com:lucky_blog.git
[submodule "web/old"]
    url = git://amygdala.servebeer.com:old_lucky.git

你尝试过:移除第一个块。复制第二个块,然后在该第二块中将“old”替换为“blog”?(同时颠倒顺序,并确保原始第一个块中没有任何可能导致错误的特殊字符) - VonC
你能展示一下.git/config中与子模块相关的内容吗? - dmedvinsky
VonC:复制似乎没有起作用。dmedvinsky:已添加配置供您参考。 - Octaflop
1个回答

12

您的git网址格式略有错误 - 您应该使用/而不是:将主机与路径分开。 尝试将网址更改为:

git://amygdala.servebeer.com/lucky_blog.git
git://amygdala.servebeer.com/old_lucky.git

你不仅需要将那些更改提交到.gitmodules,还需要使用以下命令更改配置:

$ git config submodule.web/blog.url git://amygdala.servebeer.com/lucky_blog.git
$ git config submodule.web/old.url git://amygdala.servebeer.com/old_blog.git

...并且为了确保子模块被重新克隆,需要将其删除,然后再尝试执行git submodule update


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接