Git submodule add: “a git directory is found locally” issue 解决方法
问题描述:
当添加一个最近刚被删除的同名submodule时会提示:Git submodule add: “a git directory is found locally” issue
解决方法:
首先:
git rm --cached path_to_submodule
rm -rf path_to_submodule
然后:
删除.gitmodules文件中的对应行:
[submodule "path_to_submodule"]
path = path_to_submodule
url = https://github.com/path_to_submodule
删除.git/config文件中的对应行:
[submodule "path_to_submodule"]
url = https://github.com/path_to_submodule
rm -rf .git/modules/path_to_submodule
最后即可重新添加submodule:
git submodule add https://github.com/path_to_submodule
补充:
在git中删除尽量使用git rm,而不是直接将文件或文件夹删除!