\`git clone\`如何包括子模块?

谷若汐

2018-10-29

我正在尝试将子模块放入回购。

问题是当我克隆父repo时,子模块文件夹是完全空的。

是否有任何方法可以使'git clone parent'实际将数据放入子模块文件夹中?

例如:http://github.com/cwolves/sequelize/tree/master/lib/

nodejs-mysql-native指向外部git,但是当我签出sequelize项目时,该文件夹为空...

第92篇《\`git clone\`如何包括子模块?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
Winter 2018.10.29

With version 2.13 of Git and later, --recurse-submodules can be used instead of --recursive:

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

Editor’s note: -j8 is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel — see man git-clone.

With version 1.9 of Git up until version 2.12 (-j flag only available in version 2.8+):

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

With version 1.6.5 of Git and later, you can use:

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

For already cloned repos, or older Git versions, use:

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

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android