- 简述下出现的情况:
- 1.之前从github上,clone了一个clockpicker的插件,然后,直接将整个版本库,复制到了项目中
- 2.发现版本库中,并未记录到该目录!查看 '.gitignore' 等,也并未找到忽略该目录
- 3.进入clockpicker目录下,发现有.git, .gitignore,因为原本就是完整的一个git仓库,猜想和这个有关,然后删除的只剩下 dist, src。然后 git status 查看,发现扔未记录
- 4.强制 git add dist 目录,出现错误:
- fatal: Pathspec 'dist/' is in submodule 'public/components/clockpicker'
- 5.google搜索:
- https://stackoverflow.com/questions/24472596/git-fatal-pathspec-is-in-submodule
- 原因解释:
- 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.
- 在我的主项目中,我clone一个git扩展,并运行了git add,并没有想太多。在这种情况下,git会创建一个子模块(也就是报错中的submodule),然后,就同我上面的第3步一样,将.git等等都删除了。然后运行git add 报错!
- -----------------
- 不懂,反正大概意思了解就行,尽量不要在我们的项目中,再引入其他git仓库,我们自己都觉得不太对劲...
- 解决方案:
- git rm --cached clockpicker
- git add clockpicker才能够
- 做项目的时候特别是添加别的模块的时候,尽量手动拷贝或者全部新建,不知道稀里糊涂的添加了什么文件,然后就一路被坑了
git 出现 fatal: Pathspec 'assets/' is in submodule 'public/components/clockpicker',解决方法是
最新推荐文章于 2024-08-08 17:11:10 发布