How to `git clone` including submodules?
I'm trying to put a submodule into a repo.
The problem is that when I clone the parent repo, the submodule folder is entirely empty.
Is there any way to make it so that 'git clone parent' actually puts data in the submodule folder?
example: http://github.com/cwolves/sequelize/tree/master/lib/
nodejs-mysql-native is pointing at an external git, but when I checkout the sequelize project, that folder is empty...
With version 2.13 of Git and later, --recursive has been deprecated and --recurse-submodules should be used instead:
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
在子模块被填充之前,你必须做两件事:
git submodule init
git submodule update
Original answer 2010
As joschi mentions in the comments, git submodule now supports the --recursive option (Git1.6.5 and more).
If --recursive is specified, this command will recurse into the registered submodules, and update any nested submodules within.
See Working with git submodules recursively for the init part.
See git submodule explained for more.
With version 1.6.5 of git and later, you can do this automatically by cloning the super-project with the –-recursive option:
git clone --recursive git://github.com/mysociety/whatdotheyknow.git
Update 2016, with git 2.8: see "How to speed up / parallelize downloads of git submodules using git clone --recursive ?"
You can initiate fetching the submodule using multiple threads, in parallel.
For instances:
git fetch --recurse-submodules -j2
链接地址: http://www.djcxy.com/p/2700.html
下一篇: 如何`git克隆`包括子模块?
