Janniks Blog

Delete git submodule

June 10, 2019

mirror from https://gist.github.com/myusuf3/7f645819ded92bda6677

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
git add .gitmodules
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run (no trailing slash)
git rm --cached path_to_submodule
  • Run (no trailing slash)
rm -rf .git/modules/path_to_submodule
  • Run
git commit -m "Removed submodule "
  • Delete the now untracked submodule files
rm -rf path_to_submodule

Copyright © Jannik Buschke 2022