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

Git submodule add: “a git directory is found locally” issue 解决方法

参考链接: https://stackoverflow.com/questions/20929336/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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章