可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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...
回答1:
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
回答2:
You have to do two things before a submodule will be filled:
git submodule init
git submodule update
回答3:
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
回答4:
You can use this command to clone your repo with all the submodules:
git clone --recursive YOUR-GIT-REPO-URL
Or if you have already cloned the project, you can use:
git submodule init
git submodule update
回答5:
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>
回答6:
Try this:
git clone --recurse-submodules
It automatically pulls in the submodule data assuming you have already added the submodules to the parent project.
回答7:
late answer
// git CLONE INCLUDE-SUBMODULES ADDRESS DESTINATION-DIRECTORY
git clone --recursive https://USERNAME@bitbucket.org/USERNAME/REPO.git DESTINATION_DIR
As I just spent a whole hour fiddling around with a friend: Even if you have Admin rights on BitBucket, always clone the ORIGINAL repository and use the password of the one who owns the repo. Annoying to find out that you ran into this minetrap :P
回答8:
Try this for including submodules in git repository.
git clone -b <branch_name> --recursive <remote> <directory>
or
git clone --recurse-submodules
回答9:
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
回答10:
Try this.
git clone -b <branch_name> --recursive <remote> <directory>
If you have added the submodule in a branch make sure that you add it to the clone command.