There is git submodule add
, but no git submodule remove
. That one is called git submodule deinit
, but still a lot of links on the internet do not mention it, so I’m glad there is a good answer to [WayBack] github – What is the current way to remove a git submodule? – Stack Overflow:
You have the
git submodule deinit
git submodule deinit <asubmodule> git rm <asubmodule> # Note: asubmodule (no trailing slash) # or, if you want to leave it in your working tree git rm --cached <asubmodule> rm -rf .git/modules/<asubmodule>
deinit
Un-register the given submodules, i.e. remove the whole
submodule.$name
section from.git/config
together with their work tree.Further calls to
git submodule update
,git submodule foreach
andgit submodule sync
will skip any unregistered submodules until they are initialized again, so use this command if you don’t want to have a local checkout of the submodule in your work tree anymore.If you really want to remove a submodule from the repository and commit that use
git rm
instead.If
--force
is specified, the submodule’s work tree will be removed even if it contains local modifications.
–jeroen