0

I have removed the existing submodule from my Git repository using commands found in the following answer: How do I remove a Git submodule?

Although the submodule has been removed (the directory is gone, and the changes have been committed) the submodules still appear in .gitmodules just as they were before the removal. The strange thing is, Git doesn't seem to mind that they are listed there, and pretends as if they weren't. git status tells me everything is okay, and even running git submodule init won't re-add the submodules deleted but still listed there.

Can someone please explain why my deleted submodules still showing up in .gitmodules? What is the significance and the role of the .gitmodules file in Git’s internal workflow? And related, is there any harm deleting the .gitmodules file now that I am no longer using it?

Community
  • 1
  • 1
IQAndreas
  • 8,060
  • 8
  • 39
  • 74

1 Answers1

0

Is there any harm deleting the .gitmodules file now that I am no longer using it?

If you are 100% sure you are not using submodules, then you should be 100% safe removing the .gitmodules file.

But I assume the process you went through was something like this. Assuming your submodule is named spiro_agnew:

git submodule deinit spiro_agnew

Then you can just remove the files connected to that submodule like this:

git rm -rf spiro_agnew

Then just do this to be free of the .gitmodules entirely:

git rm .gitmodules
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • Doesn't answer my first question (which you mercilessly edited out ;) – IQAndreas May 07 '14 at 01:13
  • “…the submodules still appear in .gitmodules just as they were before the removal.” Who cares at this point if they appear there? Just do a `git rm .gitmodules`. That is why I edited your question. It’s a non-issue at this point. – Giacomo1968 May 07 '14 at 01:17
  • I want to know the significance and the role of the `.gitmodules` file in Git's internal workflow. Is it used by git to keep track of the submodules (like a config file), or just there to assist the user (like a stage that prevents the user from having to mess with GITs internal config files)? What about if someone else clones my repository; will the existence of the "old" `.gitconfig` file have an effect on them? – IQAndreas May 07 '14 at 01:21
  • @IQAndreas Well, I understand your curiosity, but honestly—from my real world experience dealing with git submodule headaches—it’s just better to get rid of them and move on. Not too sure what the `old` `.gitconfig` refers to. If you go through the steps I have outlined, you will have to do a `git commit -a -m` and that would wipe out all signs of the submodule. I understand their intended use, but find they end up being—sorry to say—a cancer in a repo at times. Better just move on. Seriously. – Giacomo1968 May 07 '14 at 01:24
  • That was a typo, I meant "old .gitcommit". And believe me, I know of the headaches that come with submodules; yet once you learn to use them properly, they become a beautiful asset. – IQAndreas May 07 '14 at 01:40