
How you can effectively delete a git submodule
Every now and then you need to delete a Git submodule. Since you don't do this often, you quickly forget how to do it. Here is a short tutorial for the next time.
- Delete the relevant section in .gitmodules
- Stage the .gitmodules changes with git 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 (no trailing slash)
- Commit git commit -m "Removed submodule"
- Delete the now untracked submodule files with rm -rf path_to_submodule