Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the git submodule name used for anything other than display?

The .gitmodules file used to track submodules within a git repository normally has a name for each submodule, like this:

[submodule "my-submodule"]
  path = foo/bar/my-submodule
  url = http://github.com/myuser/original-my-submodule

However, I've also seen it written with the local path duplicated in the submodule name:

[submodule "foo/bar/my-submodule"]
  path = foo/bar/my-submodule
  url = http://github.com/myuser/original-my-submodule

I have both of these styles in one of my repositories, probably by accident, and I'm not sure why they are different.

I'd like to make sure I have these expressed correctly. Which of these is "correct"? Does it matter? Is the submodule name used for anything other than display?

like image 475
Andrew Ferrier Avatar asked Oct 21 '22 10:10

Andrew Ferrier


1 Answers

The gitmodules man page includes:

The file contains one subsection per submodule, and the subsection value is the name of the submodule.
The name is set to the path where the submodule has been added unless it was customized with the --name option of git submodule add.

It is then possible that a submodule is added (git submodule add) twice, with and without the --name option ("without" means: its default "name" used in the .gitmodules is its path, like foo/bar/my-submodule).

It doesn't seem to matter to git submodule add, since it is generally used with the --name option as well, using one of the two entries of the .gitmodules.
A git submodule add without --name would use the second entry of the .gitmodules.

If both url are the same in those two entries... the result of git submodule add command is the same.
Beside 'add', the name isn't used elsewhere.

like image 189
VonC Avatar answered Oct 24 '22 04:10

VonC