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

The .gitmodules file used to track submodules in the git repository usually has a name for each submodule, for example:

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

However, I also saw that it was written with a local path duplicated in the name of the submodule:

 [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, perhaps by accident, and I'm not sure why they are different.

I would like to make sure that I formulated it correctly. Which one is "correct"? Does it matter? Is the submodule name used for anything other than display?

+4
source share
1 answer

gitmodules man page includes:

The file contains one subkey per submodule, and the value of the subsection is the name of the submodule. The name is set to the path to which the submodule was added, if it was not configured with the --name git submodule add option .

Then it is possible that the submodule is added ( git submodule add ) twice, with the --name option and without it ("without" means: its default "name" used in .gitmodules is its outline, for example foo/bar/my-submodule ).

git submodule add does not seem to matter, as it is usually used with the --name option, using one of the two .gitmodules entries.
An additional git submodule without --name will use the second .gitmodules entry.

If both urls are the same in these two entries ... the result of the git submodule add same.
Apart from add, the name is not used elsewhere.

+2
source

Source: https://habr.com/ru/post/1479923/


All Articles