Remove the submodule entry from .git/config1
git submodule deinit -f path/to/submodule
Remove the submodule directory from the superproject’s .git/modules directory1
rm -rf .git/modules/path/to/submodule
Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule1
git rm -f path/to/submodule
Remove cached entries; Delete .gitmodules before doing this, if it hasn’t deleted already2
rm -rf path/to/submodule