1

Somewhere in the course of committing and pushing code individually in my submodules, the root repo suddenly thinks that code in my submodule is actually part of the root repo; that is, files that are part of the submodule are now appearing as unstaged files to be added in the root repo. I verified this by running git status.

It's almost as if git forgot there are such things as submodules and thinks I added all these files. I did notice that the submodule has a .git file not a .git directory. In the file has this line

gitdir: ../.git/modules/root-repo

and the root repo has a .git/modules/sub-repo folder as expected.

How do I get back to the correct state?

I suppose I can clone the root repo again and recursively update the submodules, but that seems heavy handed.

Kit
  • 20,354
  • 4
  • 60
  • 103

1 Answers1

0

I suppose I can clone the root repo again and recursively update the submodules

That would be a good first state, in order to check:

  • you still have a .gitmodules file which lists those submodules paths
  • the root folders of those submodules are still considered gitlinks, as shown here:

    cd /parent/folder/of/submodule
    git ls-files | grep 160000
    
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250