Frequently used commands for Git submodules.
TO add the reference to another git project as a submodule:
git submodule add $url $path
git submodule update --init --recursive
Alternatively, you can use GUI tools like or GitHub desktop. They download and initiate submodules automatically.
Add you will see the file .gitmodules
with information about the submodule(s). For instance,
.gitmodules[submodule "themes/DoIt"]
path = themes/DoIt
url = https://github.com/HEIGE-PCloud/DoIt.git
With -b $branch
option
git submodule add -b $branch $url $path
Or set-branch -b $branch
if you already have added a submodule
git submodule set-branch -b $branch $path
From a stackOverflow post and Git docs
git submodule update --remote --merge
For automated updates by bots, see automatic dependency update.
From Git docs
# Remove submodule from config
git submodule deinit $path
# Delete submodule tracking data
git rm <submodule path> && git commit
# Complete removal
rm -rf $GIT_DIR/modules/$name/