Git:Submodules
lastmod 2026-02-24created 2016-03-204 edits
Command
-
git submodule add {repository_url} - Adds a submodule.
-
git submodule init - Initializes. Must be run after a repository clone.
-
git submodule update - Updates the modules that have changed.
Remove submodule
To remove a submodule:
- Delete the relevant section from the
.gitmodulesfile. - Stage the .gitmodules changes
git add .gitmodules - Delete the relevant section from
.git/config. - Run
git rm --cached path_to_submodule(no trailing slash). - Run
rm -rf .git/modules/path_to_submodule - Commit
git commit -m "Removed submodule {name}" - Delete the now untracked submodule files
-
rm -rf path_to_submodule