git - 我如何 "git clone"一个 repo,包括它的子模块?

标签 git git-submodules

我如何克隆一个 git 存储库以便它也克隆它的子模块?

运行 git clone $REPO_URL 只会创建空的子模块目录。

最佳答案

在 Git 2.13 及更高版本中,可以使用 --recurse-submodules 代替 --recursive:

git clone --recurse-submodules -j8 git://github.com/foo/bar.git
cd bar

编者注:-j8 是一个可选的性能优化,在 2.8 版中可用,一次可以并行获取多达 8 个子模块 — 请参阅 man git-clone .

Git 1.9 到 2.12 版(-j 标志仅在 2.8+ 版中可用):

git clone --recursive -j8 git://github.com/foo/bar.git
cd bar

对于 Git 1.6.5 及更高版本,您可以使用:

git clone --recursive git://github.com/foo/bar.git
cd bar

对于已经克隆的 repos,或者旧的 Git 版本,使用:

git clone git://github.com/foo/bar.git
cd bar
git submodule update --init --recursive

关于git - 我如何 "git clone"一个 repo,包括它的子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33795901/

相关文章:

node.js - 无密码和 mongostore

git - 编写 git hook 以在本地提交期间自动修改代码

git - 什么是 'dirty' 子模块?

git - 自动将所有子模块添加到仓库

linux - 如何检测子模块中父 Git 存储库的正确 GIT_DIR 和 GIT_WORK_TREE

来自子目录的 Git 子模块?

git - 我似乎无法在命令行中更改文件的访问权限

git - 将 GitHub 存储库同步到 Azure DevOps

bash - 我可以禁用特定的 git 命令吗?

git - 无法 checkout git 子模块路径