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?
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 ofgit 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With