Git 子模块完全拒绝合作

Git submodule completely refusing to cooperate

我有两个存储库。 BigRepo 和 SmallRepo。

我想让 SmallRepo 成为 BigRepo 的子模块。

我做了什么?

我首先克隆了 BigRepo。

那我运行

git submodule add git://github.com/Karlovsky120/SmallRepo.git submodules\SmallRepo

成功将 SmallRepo 克隆到 BigRepo。

现在我 运行 git status 得到了:

new file: .gitmodules
new file: submodules/SmallRepo

如果我 运行 git submodule init 它失败并显示消息:

fatal: No url found for submodule path 'submodules/SmallRepo' in .gitmodules

(我知道它已经初始化了,但是 url 就在那里)。

我也尝试提交并推送更改,然后删除本地存储库以再次克隆它,但它会失败并显示相同的消息。

我知道当我推送更改时,子模块出现在网络界面中,但我无法点击它。我不知道这是不是正常行为。

我已经查阅(并遵循)了一堆教程,但我不知道为什么会这样。本来应该超级简单的,最基本的例子却失败了。

我做错了什么?

编辑:

.gitmodules 的内容是:

[submodule "submodules\SmallRepo"]
    path = submodules\SmallRepo
    url = git://github.com/Karlovsky120/SmallRepo.git

如果您没有路径限制,那么应该执行以下操作:

$ git submodule add git://github.com/chenrui333/config-repo.git SmallRepo
$ git submodule init


$ cat .gitmodules 
[submodule "SmallRepo"]
    path = SmallRepo
    url = git://github.com/chenrui333/config-repo.git

$ ls SmallRepo/
README.md test

我只用了一级路径,我想可能是这个原因。

[更新]

原来是路径问题,修改脚本更新:

$ git submodule add git://github.com/chenrui333/config-repo.git SmallRepo/config
$ git submodule init


$ cat .gitmodules 
[submodule "SmallRepo/config"]
    path = SmallRepo/config
    url = git://github.com/chenrui333/config-repo.git

$ ls SmallRepo/config/
README.md test