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
Atharva Raykar <raykar.ath@gmail.com>
Date
Aug 5, 2021, 18:38 UTC
Message-ID
<m2bl6bvit1.fsf@gmail.com>
In-Reply-To
<CANt7McE4N0wv5bik8tSNrdTs-mcL20cJPMP42iPtZqhUpKgirA@mail.gmail.com>
Rostislav Krasny <rosti.bsd@gmail.com> writes:
Show 17 quoted lines
> On Wed, Jul 21, 2021 at 10:26 AM Atharva Raykar <raykar.ath@gmail.com> wrote:
>> [...]
>> 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. [...]

Have you tried running 'submodule update --merge' or 'submodule update --rebase'? Those modes will not detach your submodule's HEAD.

The Pro Git book has a section that explains a workflow that sounds similar to what you describe:

https://git-scm.com/book/en/v2/Git-Tools-Submodules

Around halfway down the page, look for the heading "Working on a Submodule". Does that fit your use case?

> [...] Google is full of questions about how this could be done, i.e. there
> is an essential demand of such a new behavior.

It would be nice if you can share a specific link that captures the demand you are talking about. When I Googled about this behaviour, I got a range of different kinds of results, without a clearly voiced demand. If you can show an example that best represents this demand, the Git developers here may be able to address it better.

Previous: Rostislav KrasnyNext: Torsten B��gershausen
Message 7 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.