Skip to Content

How to delete git submodule

Posted on

My blog use hugo framework, and install theme by using git submodule.

Each time I change my theme, I want to completely remove submodule of old themes.

Solution

  • Open .gitmodules files, remove relevant section.
  • Stage the .gitmodules changes: git add .gitmodules
  • Open .git/config, remote relevant section.
  • Run git rm --cached path_to_submodule
  • Run rm -rf .git/modules/path_to_submodule
  • Commit git commit -m "Removed submodule"
  • Delete the submodule: rm -rf path_to_submodule

Reference: https://gist.github.com/myusuf3/7f645819ded92bda6677

comments powered by Disqus