Git: fatal: Pathspec is in submodule

出现是问题:

git提交代码是出现fatal: Path 'directory/file' is in submodule 'directory''错误

 

Removing the directory from git and adding it again worked for me:

 git rm --cached directory
 git add directory

This works if you purposefully removed the .git directory because you wanted to add directory to your main git project. In my specific case, I had git cloned an extension and ran git add . without thinking too much. Git decided to create a submodule, which I didn't like. So I removed directory/.git and ran into Git: fatal: Pathspec is in submodule. I couldn't find out how to remove the submodule stuff. Fixed with the two lines above.

  

 

posted @ 2018-12-18 17:04  Oops!#  阅读(1896)  评论(0编辑  收藏  举报