git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Why does adding an existing repo as a submodule modify .git/config?

From
Jens Lehmann <jens.lehmann@web.de>
Date
May 23, 2011, 18:43 UTC
Message-ID
<4DDAAAD2.1010708@web.de>
In-Reply-To
<irbq5a$h38$1@dough.gmane.org>
Am 22.05.2011 22:02, schrieb Christopher Wilson:
Show 47 quoted lines
> (I posted this question below on
> http://stackoverflow.com/questions/6083357/why-does-adding-an-existing-repo-as-a-submodule-modify-git-config
> and was recommended to ask the mailing list)
> 
> 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.
> 
> I'm aware this is intentional behavior
> (https://github.com/git/git/commit/c2f939170c65173076bbd752bb3c764536b3b09b),
> but I don't understand why.
> 
> Why is .git/config modified in the second case but not the first? Can
> somebody explain the rational for this behavior?

Hmm, this looks like an inconsistency to me too. It would be great to hear about the background, so I added Mark to the CC, maybe he can shed some light.

Previous: Christopher WilsonNext: Mark Levedahl
Message 2 of 7 in “Why does adding an existing repo as a submodule modify .git/config?”
  1. Christopher WilsonMay 22, 2011
  2. Jens LehmannMay 23, 2011
  3. Mark LevedahlMay 24, 2011
  4. Christopher WilsonMay 24, 2011
  5. Mark LevedahlMay 25, 2011
  6. Christopher WilsonMay 25, 2011
  7. Jens LehmannMay 26, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.