What are the extra gits caused by the submodules?

When importing a theme into Hugo, we have to add a submodule. Deleting the .git file inside the folder or editing the submodules file doesn’t seem to do anything.

Is this intentional. Am I misunderstanding the idea of submodules?

What did you expect to see upon deleting those?

  • If you deleted a .git file that didn’t delete the git repo metadata. The submodule’s .git is inside the parent repo’s .git. I am not sure why you are deleting these files, but here’s a related SO answer.
  • If you deleted a .git directory, you deleted the git repo’s metadata and all the history.

I didn’t expect a Hugo project’s theme usage to create git repos inside of my git repos. Does this happen when you use other tools?

What are the exact commands you typed?

Just the instruction given in the Hugo quickstart.

I think downloading the theme might work too and would avoid this issue, gonna test that out.

In that step, you are adding a git submodule. So the theme git repo’s .git gets created in your repo’s .git. That’s normal.

A SO answer on how to remove git submodules.

The reason there is a .git file in that folder is because git might clean out empty folders. The created folder and the .git file are placeholders for the parent repository signalling a submodule. There are commands to check out a submodules with it’s files in place, meaning there would be a full .git directory and the files of the submodule in that folder instead of just a .git file. Because the submodule is named in your .gitmodules file, removing the .git file is not breaking anything. Leave it anyway.