How to delete git submodule
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
.gitmodulesfiles, remove relevant section. - Stage the
.gitmoduleschanges: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