Git submodules

To add a submodule:

Add submodule (another repo):

$ git submodule add <path-to-repo>

Commit and push changes.

When cloning the parent project, only empty submodule folders get pulled. To actually pull the submodules you need to initialize and update the modules.

To install a submodule:

$ git submodule init

$ git submodule update

You can do this in one go by adding –recurse-submodules.

$ git clone –recurse-submodules <path-to-repo>

If you forgot the –recurse-submodules when cloning, you can combine the ‘init’ and ‘update’ command by running:

$ git submodules update –init

And the foolproof way:

$ git submodules update –init –recursive

Posted in Git