嵌套的git仓库和子模块之间的区别 [英] Difference between nested git repos and submodules
问题描述
git version - 2.6.4
我陷入了无法克隆的情况使用 - 递归
标志完成回购内容。
我的主资源库有两个子目录 health-check
和 hellspawn
$ b 我已经创建了 hellspawn
作为子模块,并且它的条目位于 .gitmodules
文件。
我不确定 如果是这样的话,那么为什么当克隆主存储库时使用git消息? ` 正如你可以看到最后一行,如果 任何帮助 它是一个嵌套的git仓库。 子模块
或嵌套git
。
health-check
在 .gitmodules
中没有条目,这使得我可能<
admin@admins-MacBook-Pro.local:〜/ try $ git clone --recursive
git@github.com:url / mainrepo .git
克隆到'mainrepo'中...
remote:计数对象:28713,完成。
remote:压缩对象:100%(613/613),完成。
remote:合计28713(delta 363),重用5(delta 5),重复使用28090
接收对象:100%(28713/28713),788.79 MiB | 3.54 MiB / s,完成。
解决三角洲问题:完成100%(17645/17645)。
检查连通性...完成。
检出文件:100%(40522/40522),完成。
在.gitmodules中找不到用于健康检查路径的子模块映射
health-check
是嵌套的git,那么为什么git正在检入 .gitmodules
文件?
由于这个错误,即使在子模块 hellspawn
中也没有下载代码。
-check没有在.gitmodules中进入,这使得它可能是嵌套的git。
如果
健康检查
是嵌套的git,那么为什么git检入.gitmodules
file
因为嵌套的git仓库记录为 < gitlink (作为子模块),这意味着git会检查 索引中的特殊条目 匹配在 .gitmodules
文件中声明的文件(因为 -
选项,要求克隆子模块) git clone
的递归
由于该特殊条目与任何 .gitmodules
条目路径都不匹配,因此会失败并显示该警告。
由于这个错误,即使在子模块hellspawn中,我也没有下载代码
两种方法:
-
摆脱那个特殊条目:
Try和git rm --cached health-check
(无尾随'/
',正如我在git --recursive
不克隆子模块),然后添加并推送,然后再次尝试git clone --recursive
-
声明子模块
即:
git config -f .gitmodules submodule.health-check.path运行状况检查
git config -f .gitmodules submodule.health-check.url https://github.com/<auser>/health-check
(由实际使用者取代< auser>
管理该回购)
再次,添加,推送,然后尝试 git clone - 再次递归
。
git version - 2.6.4
I have stuck in a situation where I am not able to clone complete repo content using --recursive
flag.
My main repository have two sub-directory health-check
and hellspawn
.
I have created hellspawn
as submodule and it has its entry in .gitmodules
file also.
I am not sure what health-check
is, whether a submodule
or nested-git
.
health-check
does not have entry in .gitmodules
which make me thing it might be nested-git
.
if so , then why am I getting git message when cloning main repository with
admin@admins-MacBook-Pro.local:~/try$git clone --recursive
git@github.com:url/mainrepo.git
Cloning into 'mainrepo'...
remote: Counting objects: 28713, done.
remote: Compressing objects: 100% (613/613), done.
remote: Total 28713 (delta 363), reused 5 (delta 5), pack-reused 28090
Receiving objects: 100% (28713/28713), 788.79 MiB | 3.54 MiB/s, done.
Resolving deltas: 100% (17645/17645), done.
Checking connectivity... done.
Checking out files: 100% (40522/40522), done.
No submodule mapping found in .gitmodules for path 'health-check'
`
As you can see last line if health-check
is nested git then why git is checking in .gitmodules
file ??
Due to this error, I am not getting code downloaded even in hellspawn
which is submodule.
Any help
health-check does not have entry in .gitmodules which make me thing it might be nested-git.
It is a nested git repo.
if
health-check
is nested git then why git is checking in.gitmodules
file
Because a nested git repo is recorded as a gitlink (as a submodule is), which means git checks if that special entry in the index matches one declared in the .gitmodules
file (because of the --recursive
option of git clone
, asking to clone submodules)
Since that special entry does not match any .gitmodules
entry path, it fails with that warning.
Due to this error, I am not getting code downloaded even in hellspawn which is submodule
Two approaches:
Get rid of that special entry:
Try andgit rm --cached health-check
(no trailing '/
', as I mentioned in "git --recursive
doesn't clone submodule"), then add and push, and then try thegit clone --recursive
againDeclare the submodule
That is:
git config -f .gitmodules submodule.health-check.path health-check
git config -f .gitmodules submodule.health-check.url https://github.com/<auser>/health-check
(replace <auser>
by the actual user managing that repo)
Again, add, push, then try the git clone --recursive
again.
这篇关于嵌套的git仓库和子模块之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!