I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.
This is what ultimately worked for me (this article helped out a lot):
If you haven't already run
git rm --cached path_to_submodule
(no trailing slash) as well as
rm -rf path_to_submodule
Then:
- Delete the relevant lines from the
.gitmodules
file. e.g. delete these:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
- Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
Then, you can finally:
git submodule add https://github.com/path_to_submodule