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_submoduledeletesthe_submodules’ entry from .git/config. This excludes the_submodule fromgit submodule update,git submodule syncandgit submodule foreachcalls and deletes its local content (source). Also, this will not be shown as change in your parent repository.git submodule initandgit submodule updatewill restore the submodule, again without commitable changes in your parent repository.git rm the_submodulewill remove the submodule from the work tree. The files will be gone as well as the submodules’ entry in the.gitmodulesfile (source). If onlygit rm the_submodule(without priorgit submodule deinit the_submoduleis run, however, the submodules’ entry in your .git/config file will remain.
Taken from here:
- Delete the relevant section from the
.gitmodulesfile. - Stage the
.gitmoduleschangesgit 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