Git submodule add: "a git directory is found locally" issue
Solution 1:
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 rungit rm --cached path_to_submodule
(no trailing slash) as well asrm -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
Solution 2:
i tried jbmilgrom's solution, specifically i tried git rm --cache
and that didn't work for me either as the directory/submodule wasn't there. What worked for me was:
rm -rf .git/modules/blah
-
git submodule add git://path.to.new
I did this after trying --force
within the git submodule
commands and rm
all the other directories, pushes to master etc... the directory didn't exist and there was no reason for the cache. Turns out in .git/modules
that is where this error was lying.