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

Re: [PATCH 0/3] worktree: add --recurse-submodules support to git worktree add

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2026, 17:05 UTC
Message-ID
<xmqqzf3225u1.fsf@gitster.g>
In-Reply-To
<aeEMU-ohKz2tnSWq@RTX>
Jimmy Aguilar Mena <kratsbinovish@gmail.com> writes:
Show 6 quoted lines
> The approach follows Phillip Wood's and Junio's feedback: each linked
> worktree gets its own per-worktree submodule gitdir under
> $GIT_COMMON_DIR/worktrees/<id>/modules/<name>/, so HEAD, refs, and
> the index are independent per worktree while pack files and loose
> objects are shared via hardlinks.  The gitdir isolation is the same
> model git worktree already uses for the superproject.

I do not quite follow. The point of git-native worktree support (which improved a lot compared to its precursor, "git-new-workdir", is that it can work well in a hardlink-challenged platforms. You shouldn't worry about "hardlinking" yourself at all.

After the superproject successfully did "submodule init", you can move the submodule's repository with "absorbgitdirs" to $GIT_DIR/modules/<submodule>/ of the superproject. The primary motivation behind this feature was that you can switch to a commit in the superproject that does *not* have the submodule bound to it at all (and obviously you do not want to lose the submodule repository only because you tentatively switch to such a commit and have to re-download when you switch back), but I think it gives the single instance of submodule repository that you can share across worktrees of the submodule. Because the single directory created with "absorbgitdirs" looks like a bare repository, you should be able to create two worktrees off of that, with their own HEAD etc.

Previous: Jimmy Aguilar MenaNext: Phillip Wood
Message 2 of 4 in “worktree: add --recurse-submodules support to git worktree add”
  1. 0/3 worktree: add --recurse-submodules support to git worktree addJimmy Aguilar Mena, Apr 16, 2026
  2. Junio C HamanoApr 16, 2026
  3. Phillip WoodApr 16, 2026
  4. Phillip WoodApr 17, 2026

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.