Git submodule add: “a git directory is found locally” issue

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:

  1. 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
  1. Delete the relevant section from .git/config. e.g. delete these:
[submodule "path_to_submodule"]
        url = https://github.com/path_to_submodule
  1. rm -rf .git/modules/path_to_submodule

Then, you can finally:

git submodule add https://github.com/path_to_submodule

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)