How to `git clone` including submodules?

2019-01-01 00:57发布

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...

10条回答
看淡一切
2楼-- · 2019-01-01 01:52

If your submodule was added in a branch be sure to include it in your clone command...

git clone -b <branch_name> --recursive <remote> <directory>
查看更多
何处买醉
3楼-- · 2019-01-01 01:59

Try this:

git clone --recurse-submodules

It automatically pulls in the submodule data assuming you have already added the submodules to the parent project.

查看更多
无与为乐者.
4楼-- · 2019-01-01 02:01

You have to do two things before a submodule will be filled:

git submodule init 
git submodule update
查看更多
骚的不知所云
5楼-- · 2019-01-01 02:01

Submodules parallel fetch aims at reducing the time required to fetch a repositories and all of its related submodules by enabling the fetching of multiple repositories at once. This can be accomplished by using the new --jobs option, e.g.:

git fetch --recurse-submodules --jobs=4

According to Git team, this can substantially speed up updating repositories that contain many submodules. When using --recurse-submodules without the new --jobs option, Git will fetch submodules one by one.

Source: http://www.infoq.com/news/2016/03/git28-released

查看更多
登录 后发表回答