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_repo
actually puts data in the submodule folder?
For example, http://github.com/cwolves/sequelize/tree/master/lib/, nodejs-mysql-native
is pointing at an external git submodule, but when I checkout the sequelize
project, that folder is empty.
You can use the --recursive flag when cloning a repository. This parameter forces git to clone all defined submodules in the repository.
When you clone a repository, you copy the repository from GitHub.com to your local machine. Cloning a repository pulls down a full copy of all the repository data that GitHub.com has at that point in time, including all versions of every file and folder for the project.
Once you have cloned a repository, you won't need to clone it again to do regular development. The ability to work with the entire repository means that all developers can work more freely. Without being limited by which files you can work on, you can work on a feature branch to make changes safely.
When you clone a repository, any changes you push to GitHub will affect the original repository. To make changes without affecting the original project, you can create a separate copy by forking the repository.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With