我如何克隆一个 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/