When working with Git submodules, there's no simple equivalent to
git submodule add to remove a submodule you no longer need. Removing submodules requires a little bit of manual editing and a couple of commands to achieve:
git submodule deinit --all
- Delete the submodule from the
.gitmodulesfiles. It should look something along the lines of:
[submodule "module"] path = contrib/module url = https://github.com/aevitas/repository.git
- Stage your
.gitmodulesfile by running
git add .gitmodules.
git rm --cached path/to/submoduleto remove the files associated with the submodule from the index
- Finally, remove the module from git's index by running
rm -rf .git/modules/[module name].
That's all there's to it - you're now free to delete the files associated with the submodule. After a commit, the submodule will no longer be part of the repository.
Hope this helps!