Git: fatal: Pathspec is in submodule

jmite picture jmite · Jun 29, 2014 · Viewed 76.7k times · Source

I'm trying to get TravisCI to automatically deploy my Hakyll static site, according to this guide.

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.

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'

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?

You can view the repository here.

Answer

kqw picture kqw · Jul 7, 2015

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.