小编典典

如何“git clone”包括子模块?

git

我正在尝试将子模块放入回购中。问题是当我克隆父仓库时,子模块文件夹完全是空的。

有什么办法可以git clone parent_repo将数据实际放入子模块文件夹中?

例如, http : //github.com/cwolves/sequelize/tree/master/lib/nodejs-mysql-native指向一个外部 git 子模块,但是当我签出sequelize项目时,该文件夹是空的。


阅读 233

收藏
2022-02-08

共1个答案

小编典典

对于 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

对于已克隆的存储库或较旧的 Git 版本,请使用:

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