Git:致命:Pathspec 在子模块中 [英] Git: fatal: Pathspec is in submodule
问题描述
根据 本指南.
这是我的存储库的设置方式.我有我的源分支,其中包含我的 hakyll 和 markdown 文件.它将 html 构建到 _site
目录中,该目录设置为子模块,链接到我的 master
分支.
Here's how my repo is set up. I have my source branch, which contains my hakyll and markdown files. It builds the html into the _site
directory, which is set up as a submodule, linked to my master
branch.
我建立网站没有问题,然后 cd
进入 _site 目录.但是,当我尝试 git add ./*
新生成的 HTML 文件时,出现以下错误:
I build the site without problem, then cd
into the _site directory. However, when I try to git add ./*
the newly generated HTML files, I get the following error:
fatal: Pathspec './about.html' is in submodule '_site'
当我尝试 git add --all
时,出现此错误:
When I try git add --all
, I get this error:
git: pathspec.c:317: prefix_pathspec: Assertion `item->nowildcard_len <= item->len && item->prefix <= item->len' failed.
/home/travis/build.sh: line 245: 1566 Aborted git add --all
这是什么原因造成的,我该如何避免?
What is causing this, and how can I avoid this?
您可以在此处查看存储库.
推荐答案
从 git 中删除目录并再次添加它对我有用:
Removing the directory from git and adding it again worked for me:
git rm --cached directory
git add directory
如果您有意删除 .git
目录,因为您想将 directory
添加到您的主 git 项目,这将起作用.在我的特定情况下,我让 git 克隆了一个扩展并运行 git add .
没有考虑太多.Git 决定创建一个我不喜欢的子模块.所以我删除了 directory/.git
并遇到了 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.
这篇关于Git:致命:Pathspec 在子模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!