How to delete a git submodule 15 October 2013

Git is a very powerful, fast and easy VCS (version control system). Adding a sub-module is very easy, however deleting one is not. So I googled it up and tried this solution that was on stackoverflow.

  • 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
  • Commit
  • Delete the now untracked submodule files
  • rm -rf path_to_submodule