Git submodule
Frequently used commands for Git submodules.
Add a submodule¶
TO add the reference to another git project as a submodule:
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
Track a specific branch in the submodule¶
With -b $branch
option
Or set-branch -b $branch
if you already have added a submodule
Update all Git submodules to the latest commit¶
From a stackOverflow post and Git docs
For automated updates by bots, see automatic dependency update.
Remove a submodule¶
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/