I’m more likely to choose a monorepo solution if possible and I generally dislike the submodule feature in git but as always there are valid use cases (e.g. think about building a platform instead of a system).
So I put git submodules to work and immediately started doing the same mistake again and again: typos in the directory name for the module.
Now, just changing the entries in the .gitmodules file is not enough to get the module out of the way, we also need to remove the repository index entries.
To cleanly remove a git submodule you need the following:
git submodule deinit module git rm typoed_module_dir git commit -m "Removed submodule module" rm -rf .git/modules/typoed_module_dir
You then add the submodule back (after you have checked the spelling this time) and obviously explicitly set the branch and the checkout directory so that you can verify everything is typed correctly.
git submodule add -b master https://git.host/module.git CorrectlySpelledDir git submodule init