【发布时间】:2015-03-22 12:05:03
【问题描述】:
一个 git 子模块是否可以由几个其他 git 子模块组成,超级 git repo 可以获取每个子模块的内容?
作者假设 git 子模块层次结构如下:
- 回购1
- 子模块 xyz1
- 子模块 xyz2
- repo2
- 子模块 repo1
这个问题是关于在子模块中嵌套子模块的可能性:
- 回购1
- 子模块 a
- 子模块 ab
- 子模块 ac
- 子模块 a
.gitmodules 的真实示例应如下所示:
[submodule "Source/V8"]
path = Source/V8
url = https://chromium.googlesource.com/v8/v8.git
[submodule "Source/V8/build/gyp"]
path = Source/V8/build/gyp
url = https://chromium.googlesource.com/external/gyp
[submodule "Source/V8/third_party/cygwin"]
path = Source/V8/third_party/cygwin
url = https://chromium.googlesource.com/chromium/deps/cygwin
[submodule "Source/V8/third_party/python_26"]
path = Source/V8/third_party/python_26
url = https://chromium.googlesource.com/chromium/deps/python_26
[submodule "Source/V8/third_party/icu"]
path = Source/V8/third_party/icu
url = https://chromium.googlesource.com/chromium/deps/icu52
[submodule "Source/V8/testing/gtest"]
path = Source/V8/testing/gtest
url = https://chromium.googlesource.com/chromium/testing/gtest
[submodule "Source/V8/testing/gmock"]
path = Source/V8/testing/gmock
url = https://chromium.googlesource.com/chromium/testing/gtest
注意子模块的路径是嵌套的:
- 源/V8
- 源码/V8/build/gyp
- 来源/V8/third_party/cygwin
我尝试了以下示例,但没有成功:
git submodule add https://chromium.googlesource.com/v8/v8.git
Source/V8
git submodule add https://chromium.googlesource.com/external/gyp
Source/V8/build/gyp
结果:
The following path is ignored by one of your .gitignore files:
Source/V8/build/gyp
Use -f if you really want to add it.
使用 git submodule add -f 结果:
Cloning into 'Source/V8/build/gyp'...
remote: Sending approximately 10.28 MiB ...
remote: Total 16486 (delta 10444), reused 16486 (delta 10444)
Receiving objects: 100% (16486/16486), 10.28 MiB | 2.07 MiB/s, done.
Resolving deltas: 100% (10452/10452), done.
Checking connectivity... done.
fatal: Pathspec 'Source/V8/build/gyp' is in submodule 'Source/V8'
Failed to add submodule 'Source/V8/build/gyp'
如果这种情况可以实现,请告诉我。
更新:注意这个问题是关于创建一个子模块结构,而不是初始化它。
【问题讨论】:
-
你解决了吗?
-
这个用例没有解决方案
标签: git git-submodules