为什么会这样
git clone --mirror [repo-url]
或
git clone --mirror --recursive [repo-url]
不适用于子模块。尝试 git fetch --recurse-submodules
给出错误
fatal: 拒绝获取非裸仓库的当前分支 refs/heads/master
但排除 --mirror
确实有效。
因此,如果使用 --mirror
选项克隆存储库,则无法引入子模块,除非不使用 --mirror
克隆存储库。
从工作副本运行 git submodule update --init --recursive
给出错误信息:
致命:不是 git 存储库(或任何父目录):.git
从镜像存储库运行 git submodule init
会出现以下错误消息:
致命:/usr/libexec/git-core/git-submodule 不能在没有工作树的情况下使用。
使用 GIT_WORK_TREE
和/或 GIT_DIR
环境变量也不起作用。
再次从头开始克隆存储库是唯一的选择吗?
编辑:顺便说一句,--mirror
首先是因为我在关注这个:http://jonathannicol.com/blog/2013/11/19/automated-git-deployments-from-bitbucket/
最佳答案
您使用 --mirror
标志创建的存储库是一个裸存储库(即它没有工作区)。据我所知,子模块只能初始化并下载到工作区。
更多:
关于Git clone --mirror with submodules 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37437836/