Submodules

Adding

To add a new submodule to a repo, use the following command

$ git submodule add <repo-url> path/to/folder

Cloning

To clone a repo that contains submodules we can run the following command

$ git clone —-recurse-submodules <repo-url>

Or if you’ve already cloned a repo only to later discover that it contained submodules

$ git submodule update —-init —-recursive

Updating

To update a submodule

$ cd module/
module/ $ git checkout <ref>
module/ $ git pull
module/ $ cd ..

$ git add module
$ git commit -m 'Update submodule'