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_submodule's entry from.git/config. That excludes it fromgit submodule update,git submodule sync, andgit submodule foreach, and deletes its local content (source). This alone does not change the parent repository's commit.git submodule initandgit submodule updatewill restore the submodule.git rm the_submoduleremoves the submodule from the work tree and from.gitmodules(source). If you rungit rm the_submodulewithoutgit submodule deinitfirst, the entry in.git/configremains.
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