70

When I run git submodule init, I get the following error:

No submodule mapping found in .gitmodules for path 'xxx'

I searched for a .gitmodules file and I cannot find it anywhere.

I have read this most popular SO question on the same topic. But unfortunately, I cannot solve the problem. Especially given that I no longer have .gitmodules.

According to my GitHub private repo, I still have submodules for my repository. Just that I cannot find the .gitmodules file anywhere.

Community
  • 1
  • 1
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
  • 4
    I think it might be worth noting that you can create a submodule accidentally if you git init a new repo inside of an existing repo (the definition of a "submodule"). If you do this, the .gitmodule file won't be created. – tandy Feb 18 '14 at 22:33

3 Answers3

162
  1. Make sure that there are no submodule sections in .git/config. If there are, remove them.
  2. Do git rm --cached <path_to_submodule>.
kirelagin
  • 13,248
  • 2
  • 42
  • 57
5

just got over the same issue yesterday, after having deleted by hand the entry in .gitmodules (e.g. nano .gitmodules), I had to go with

git rm --cached <pathtomodule> 

which returned a message

rm '<pathtomodule>'

then I needed a

git commit -m "delete cached modules"

and validated the submodule deletion.

TianaR
  • 119
  • 1
  • 4
3

In addition to the above I also had to remove .gitmodules.

Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
AndreiMotinga
  • 1,024
  • 17
  • 24
  • In my case I didn't delete the entire file, but removed the now invalid entries and things started working again. Thanks! – KidIcarus271 Oct 24 '16 at 22:39