It add the submodule:
git submodule add -b <branch> <repository_url> <diretory_path>
Cloning a project who has submodules, use the clone command with the option --recurse-submodules
. It will garantee submodules are also cloned.
git clone --recurse-submodules <repository_url>
If you already cloned and forgot the option, you can update submodules using the command:
git submodule update --init --recursive
Use git submodule update
to update them later. Add --recursive
to all nested submodules (submodules inside other submodules) are also updated.