Removing a submodule
suggest changeYou can remove a submodule (e.g. the_submodule
) by calling:
$ git submodule deinit the_submodule
$ git rm the_submodule
git submodule deinit the_submodule
deletesthe_submodule
s’ entry from .git/config. This excludes the_submodule fromgit submodule update
,git submodule sync
andgit submodule foreach
calls and deletes its local content (source). Also, this will not be shown as change in your parent repository.git submodule init
andgit submodule update
will restore the submodule, again without commitable changes in your parent repository.git rm the_submodule
will remove the submodule from the work tree. The files will be gone as well as the submodules’ entry in the.gitmodules
file (source). If onlygit rm the_submodule
(without priorgit submodule deinit the_submodule
is run, however, the submodules’ entry in your .git/config file will remain.
Taken from here:
- Delete the relevant section from the
.gitmodules
file. - Stage the
.gitmodules
changesgit 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents