如何克隆git存储库,以便它也克隆其子模块?
运行gitclone$REPO_URL只会创建空的子模块目录。
如何克隆git存储库,以便它也克隆其子模块?
运行gitclone$REPO_URL只会创建空的子模块目录。
当前回答
使用此命令克隆所有子模块的repo
git clone --recurse-submodules git@gitlab.staging-host.com:yourproject
更新所有子模块的代码
git submodule update --recursive --remote
其他回答
如果子模块被添加到分支中,请确保将其包含在克隆命令中。。。
git clone -b <branch_name> --recursive <remote> <directory>
如果是一个新项目,你可以这样做:
$ git clone --recurse-submodules https://github.com/chaconinc/YourProjectName
如果已安装,则:
$ cd YourProjectName (for the cases you are not at right directory)
$ git submodule init
$ git submodule update
尝试在git存储库中包含子模块。
git clone -b <branch_name> --recursive <remote> <directory>
or
git clone --recurse-submodules
如何“git克隆”回购,包括其子模块?
(我把它作为一个独立的答案,因为我认为这在git中很重要)
可悲的是,但在很多情况下,那些不太知情的克隆人会错过外在的东西:
vc大便(https://github.com/dirk-thomas/vcstool)数字子报表(https://github.com/ingydotnet/git-subrepo)git链接(https://github.com/chronoxor/gil).gitsvnextmodule(由smartgit处理)。git外部(https://github.com/develer-staff/git-externals)git x模块(https://gitmodules.com/)等等
作为备份,无法创建裸克隆(--bare)+完全递归(--recursive)来镜像(--mirror)所有引用(而不仅仅是所有外部引用):使用--recursive和--bare克隆git存储库
因此,对于git,没有一种内置的方法可以完全接受外部依赖关系。这意味着没有一种方法可以完全备份任何随机git存储库。
[快速回答]
您可以使用此命令克隆包含所有子模块的repo:
git clone --recursive YOUR-GIT-REPO-URL
或者,如果您已经克隆了项目,则可以使用:
git submodule init
git submodule update