To remove a submodule you need to:
- Delete the relevant section from the .gitmodules file.
- Stage the .gitmodules changes 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 rm -rf path_to_submodule
I was using this gist for a while. It was really helpful!
However, deleting a submodule it’s a lot easier nowadays. Latest GitHub versions allows you to run:
git rm <path_to_submodule>
and git takes care of it. Afterwards you just need to commit the changes and that’s it.I hope this helps.