If I add a submodule that does not currently exist, no submodule information is added to .git/config.
$ mkdir testing
$ cd testing
$ git init
$ git submodule add git@git.server:submodule.git
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
However, if I add a repo that currently exists as a submodule, the url is added to .git/config:
$ mkdir testing
$ cd testing
$ git init
$ git clone git@git.server:submodule.git
$ git submodule add git@git.server:submodule.git
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[submodule "submodule"]
url = git@git.server:submodule.git
I would have assumed that in both cases, git submodule add would have only modified .gitmodules, and that git submodule init would have updated the project’s .git/config.
Why is .git/config modified in the second case but not the first? Can somebody explain the rational for this behavior?
This issue was fixed in https://github.com/git/git/commit/2cd9de3e18183422cd7ec3cd81cebc656068ea42