8

I have a repository on google code with my project.

I use Git source control.

It seems that when I try to add files to git from a specific directory, I get the following error:

fatal: Pathspec 'autoload_classmap.php' is in submodule 'module/CocktailMakerModule'

Now I'm not trying to add a submodule. I'm just trying to add a directory to git!

The result that I have now is that this directory is committed empty. So when I try to add specific files I get the above error message.

I checked and there isn't any other .git directory in that directory, so I'm really confused to why this has happened.

the
  • 21,007
  • 11
  • 68
  • 101
ufk
  • 30,912
  • 70
  • 235
  • 386

2 Answers2

43

Still no idea how it happened. All documentation I read assumes I have a .git directory there but I don't.

I just did the following:

git rm -rf --cached CocktailMakerModule/
git add CocktailMakerModule/

That seems to resolve the issue.

the
  • 21,007
  • 11
  • 68
  • 101
ufk
  • 30,912
  • 70
  • 235
  • 386
  • This worked for me!. I was trying to add wordpress theme to my git repo when i got this error. Thanks again that worked! :D – maths Jul 20 '14 at 07:50
  • 1
    I came to that situation by manually removing `.git` from a subdirectory. Only after I noticed that was part of a submodule. Really mangy issue this one... – ntd Sep 27 '14 at 17:54
  • I have .git and see it! But when I want to commit some files that located in a folder, it shows an error "blahblah did not match any file(s) known to git" – Dr.jacky Oct 08 '16 at 07:26
  • @ntd - same here. I manually removed a `.git` which lead to all sorts of problems! This fixed it! – featherbelly Nov 01 '16 at 09:12
1

To remove unwanted submodule, you need to unregister it by:

git submodule deinit CocktailMakerModule

then re-add the directory or file again:

git add CocktailMakerModule

Check your current outstanding submodules by: git submodule status.

For further info, check the Git manual by running: man git-submodule.


Otherwise if you want to keep this submodule, please follow: Git: fatal: Pathspec is in submodule.

Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743