gitgithubversion-controlgit-submoduleshakyll

Git: fatal: Pathspec is in submodule


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.


Solution

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

     git rm --cached <insert-your-directory-path>
     git add <insert-your-directory-path>
    

    For instance: git rm --cached /home/joey/_site/

    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.