Submodules aren’t removed using git rm submodule-dir
, they need to be removed in a far more thorough and annoying fashion.
There are a number of unclear explanations at various sources so I decided to write my own findings.
Delete the relevant parts from the
.gitmodules
file.EG:
1 2 3
[submodule "blog/themes/PaperMod"] path = blog/themes/PaperMod url = https://github.com/adityatelange/hugo-PaperMod.git
Stage .gitmodules via
git add .gitmodules
Remove the relevant parts from
.git/config
EG:
1 2
[submodule "blog/themes/PaperMod"] url = https://github.com/adityatelange/hugo-PaperMod.git
Clear the cache with
git rm --cached /path/to/submodule
- with no trailing slash. Including the trailing slash will throw an errorRemove the .git modules submodule data by running
rm -rf .git/modules/submodule_name
orrm -rf .git/modules/submodulefoldername
Commit the changes
Delete the submodule files
rm -rf path/to/submodule