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.
It automatically pulls in the submodule data assuming you have already added the submodules to the parent project. Note that --recurse-submodules and --recursive are equivalent aliases.
In order to update an existing Git submodule, you need to execute the “git submodule update” with the “–remote” and the “–merge” option. Using the “–remote” command, you will be able to update your existing Git submodules without having to run “git pull” commands in each submodule of your project.
git clone(1) --recursive. Clone a repository into a new directory. --recursive, --recurse-submodules After the clone is created, initialize all submodules within, using their default settings. This is equivalent to running git submodule update --init --recursive immediately after the clone is finished.
git submodule foreach git pull origin master or git pull origin master --recurse-submodules is what you want if you intend to update each submodule to the latest from their origin repositories. Only then will you get pending changes in the parent repo with updated revision hashes for submodules.
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
You have to do two things before a submodule will be filled:
git submodule init git submodule update
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