为什么 git 子模块更新失败?

发布于 2024-12-08 17:54:15 字数 1504 浏览 0 评论 0原文

我有以下 .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 条目(网络/旧)克隆得很好,没有任何问题。
  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 = [email protected]: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

I have the following .gitmodules file:

[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

When I clone the repo and run git submodule init && git submodule update (or git submodule init --update) I get the following error:

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

I observe three things which cause some concern:

  1. The second .gitmodules entry (web/old) is cloned just fine, with no issues.
  2. There appears to be an extra space in the error message, where I think git would normally list the hostname it fails to look up (right before the port number listing in the error listed above).
  3. git clone git://amygdala.servebeer.com:lucky_blog.git works just fine.

What is wrong with this repo? Is this an error with git or did I screw something up when setting up the repo?

Edit Here's my git config for reference:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]: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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惟欲睡 2024-12-15 17:54:15

您的 git URL 格式 稍有错误 - 您应该将使用 / 而不是 : 从路径中主机。尝试将 URL 更改为:

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

You have the format of your git URLs slightly wrong - you should separate the host from the path with / rather than :. Try changing the URLs to:

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

You will not only need to commit those changes to .gitmodules, but also change the config with:

$ 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

... and to make sure that the submodules are re-cloned, remove them and try the git submodule update again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文