public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* git submodule using worktrees?
@ 2026-03-12  8:13 Xavier Morel
  2026-03-12  8:20 ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Morel @ 2026-03-12  8:13 UTC (permalink / raw)
  To: git

I have a number of fairly large projects I work with, for that reason I 
have a bare clone for each and fork off worktrees as needed in order to 
avoid unnecessary duplication and pulls between them. That works just fine.

However when I tried to use submodules to provide a unified view of some 
of those projects I found out that there's seemingly no way to have 
submodules created as worktrees (off of a shared repository), at least 
not built-in. It seems like the submodules do set up some sort of bare 
repository / worktree situation but do not support passing in an 
existing repository to worktree off of.

`--reference` with `--dissociate` does avoid unnecessary fetches on the 
initial clone, but they do duplicate objects (and without `--dissociate` 
has all the issues of a non-static shared alternate), and do require 
duplicate fetches afterwards to update the submodules, even if the 
central local repository already has everything.

Q1: is there any way to massage the submodules into working off of a 
central shared repository? Poking around and messing with `.git/modules` 
didn't really work out but I may have just not poked the right bit, 
having to set up the submodules by hand (or via a bespoke script) is no 
issue.

Q2: is there any chance submodules will gain more first-class support 
for worktree-ing off of a local repository in the future

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git submodule using worktrees?
  2026-03-12  8:13 git submodule using worktrees? Xavier Morel
@ 2026-03-12  8:20 ` Kristoffer Haugsbakk
  2026-03-12  8:29   ` Xavier Morel
  0 siblings, 1 reply; 3+ messages in thread
From: Kristoffer Haugsbakk @ 2026-03-12  8:20 UTC (permalink / raw)
  To: Xavier Morel, git

On Thu, Mar 12, 2026, at 09:13, Xavier Morel wrote:
> I have a number of fairly large projects I work with, for that reason I
> have a bare clone for each and fork off worktrees as needed in order to
> avoid unnecessary duplication and pulls between them. That works just fine.
>
> However when I tried to use submodules to provide a unified view of some
> of those projects I found out that there's seemingly no way to have
> submodules created as worktrees (off of a shared repository), at least
> not built-in. It seems like the submodules do set up some sort of bare
> repository / worktree situation but do not support passing in an
> existing repository to worktree off of.
>
> `--reference` with `--dissociate` does avoid unnecessary fetches on the
> initial clone, but they do duplicate objects (and without `--dissociate`
> has all the issues of a non-static shared alternate), and do require
> duplicate fetches afterwards to update the submodules, even if the
> central local repository already has everything.
>
> Q1: is there any way to massage the submodules into working off of a
> central shared repository? Poking around and messing with `.git/modules`
> didn't really work out but I may have just not poked the right bit,
> having to set up the submodules by hand (or via a bespoke script) is no
> issue.
>
> Q2: is there any chance submodules will gain more first-class support
> for worktree-ing off of a local repository in the future

Does this also not work if these are regular, not-bare clones?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git submodule using worktrees?
  2026-03-12  8:20 ` Kristoffer Haugsbakk
@ 2026-03-12  8:29   ` Xavier Morel
  0 siblings, 0 replies; 3+ messages in thread
From: Xavier Morel @ 2026-03-12  8:29 UTC (permalink / raw)
  To: git


On 12/03/2026 09:20, Kristoffer Haugsbakk wrote:
> On Thu, Mar 12, 2026, at 09:13, Xavier Morel wrote:
>> I have a number of fairly large projects I work with, for that reason I
>> have a bare clone for each and fork off worktrees as needed in order to
>> avoid unnecessary duplication and pulls between them. That works just fine.
>>
>> However when I tried to use submodules to provide a unified view of some
>> of those projects I found out that there's seemingly no way to have
>> submodules created as worktrees (off of a shared repository), at least
>> not built-in. It seems like the submodules do set up some sort of bare
>> repository / worktree situation but do not support passing in an
>> existing repository to worktree off of.
>>
>> `--reference` with `--dissociate` does avoid unnecessary fetches on the
>> initial clone, but they do duplicate objects (and without `--dissociate`
>> has all the issues of a non-static shared alternate), and do require
>> duplicate fetches afterwards to update the submodules, even if the
>> central local repository already has everything.
>>
>> Q1: is there any way to massage the submodules into working off of a
>> central shared repository? Poking around and messing with `.git/modules`
>> didn't really work out but I may have just not poked the right bit,
>> having to set up the submodules by hand (or via a bespoke script) is no
>> issue.
>>
>> Q2: is there any chance submodules will gain more first-class support
>> for worktree-ing off of a local repository in the future
> 
> Does this also not work if these are regular, not-bare clones?

As in make worktrees off of non-bare clones? I don't think that would 
make any difference, to the extent that I tried things out `git 
submodule` does not seem to accept a worktree reference (a file with a 
`gitdir:` path) as repository (in `.git/modules`). Although I may have 
interpreted the error incorrectly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-12  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12  8:13 git submodule using worktrees? Xavier Morel
2026-03-12  8:20 ` Kristoffer Haugsbakk
2026-03-12  8:29   ` Xavier Morel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox