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

Re: Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...)

From
RKRostislav Krasny <rosti.bsd@gmail.com>
Date
Aug 5, 2021, 13:59 UTC
Message-ID
<CANt7McE4N0wv5bik8tSNrdTs-mcL20cJPMP42iPtZqhUpKgirA@mail.gmail.com>
In-Reply-To
<46F5B91F-4DBE-4F34-9395-7CC808FAC359@gmail.com>
On Wed, Jul 21, 2021 at 10:26 AM Atharva Raykar <raykar.ath@gmail.com> wrote:
Show 21 quoted lines
> The default mode for the update command is to checkout to the
> revision that the parent project expects the submodule to be in, ie,
> it checks out to the commit hash directly, and detaches the HEAD.
>
> Why not checkout to a branch? This is because branches may change
> which commits they point to.
>
> For example, if you had a submodule 'foo'. I go into the 'foo'
> folder and amend the last commit.
>
> Now if I run 'submodule update' in the parent repository. If it had
> checked out to the branch instead of the revision, I would be on a
> different commit in 'foo' than the one that was registered by the
> parent repo!
>
> We want to have idempotence, ie, for a particular revision that is
> registered by our parent project, we want 'update' to give the same
> outcome every time, and not be dependent on whatever the state of the
> branch is. This way we ensure that for a particular commit in the
> parent project, the submodules will be in the same state for every
> system in the world, after an 'update' is run.

All this is ok, but there could be other uses of sub-modules. Why not to make this behavior configurable?

As a developer I may want to make new commits on those sub-modules and always work with latest versions of their particular branches. In the detached HEAD mode this is much harder to be done and also an error prone operation. Commits that are done in the detached HEAD state may easily be lost. Google is full of questions about how this could be done, i.e. there is an essential demand of such a new behavior.

Previous: Philippe BlainNext: Atharva Raykar
Message 6 of 10 in “Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>"”
  1. Rostislav KrasnyJul 15, 2021
  2. brian m. carlsonJul 16, 2021
  3. Rostislav KrasnyJul 17, 2021
  4. Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...)Atharva Raykar, Jul 21, 2021
  5. Philippe BlainJul 21, 2021
  6. Rostislav KrasnyAug 5, 2021
  7. Atharva RaykarAug 5, 2021
  8. Torsten B��gershausenJul 17, 2021
  9. Rostislav KrasnyJul 17, 2021
  10. Torsten B��gershausenJul 18, 2021

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.