{"thread":{"id":"65218","subject":"git submodule using worktrees?","startedAt":"2026-03-12T08:13:15Z","lastAt":"2026-03-12T08:29:50Z","messageCount":3,"participants":["Xavier Morel","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"538725","messageId":"5152ce98-b0ce-42f2-bd34-1cc324042f88@odoo.com","threadId":"65218","inReplyTo":null,"subject":"git submodule using worktrees?","fromName":"Xavier Morel","fromEmail":"xmo@odoo.com","sentAt":"2026-03-12T08:13:12Z","receivedAt":"2026-03-12T08:13:15Z","isPatch":false,"sender":{"key":"xmo@odoo.com","avatar":"https://gravatar.com/avatar/42b8eb16dcf3bd6c1998698115b36ab6f4d69f93710caa10ff8ab04a9652ae34?d=mp&s=160"},"body":"I have a number of fairly large projects I work with, for that reason I \nhave a bare clone for each and fork off worktrees as needed in order to \navoid unnecessary duplication and pulls between them. That works just fine.\n\nHowever when I tried to use submodules to provide a unified view of some \nof those projects I found out that there's seemingly no way to have \nsubmodules created as worktrees (off of a shared repository), at least \nnot built-in. It seems like the submodules do set up some sort of bare \nrepository / worktree situation but do not support passing in an \nexisting repository to worktree off of.\n\n`--reference` with `--dissociate` does avoid unnecessary fetches on the \ninitial clone, but they do duplicate objects (and without `--dissociate` \nhas all the issues of a non-static shared alternate), and do require \nduplicate fetches afterwards to update the submodules, even if the \ncentral local repository already has everything.\n\nQ1: is there any way to massage the submodules into working off of a \ncentral shared repository? Poking around and messing with `.git/modules` \ndidn't really work out but I may have just not poked the right bit, \nhaving to set up the submodules by hand (or via a bespoke script) is no \nissue.\n\nQ2: is there any chance submodules will gain more first-class support \nfor worktree-ing off of a local repository in the future\n"},{"id":"538726","messageId":"d8e84ca2-2e86-4cdf-a1db-b6d466677fc3@app.fastmail.com","threadId":"65218","inReplyTo":"5152ce98-b0ce-42f2-bd34-1cc324042f88@odoo.com","subject":"Re: git submodule using worktrees?","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-12T08:20:21Z","receivedAt":"2026-03-12T08:20:44Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Thu, Mar 12, 2026, at 09:13, Xavier Morel wrote:\n> I have a number of fairly large projects I work with, for that reason I\n> have a bare clone for each and fork off worktrees as needed in order to\n> avoid unnecessary duplication and pulls between them. That works just fine.\n>\n> However when I tried to use submodules to provide a unified view of some\n> of those projects I found out that there's seemingly no way to have\n> submodules created as worktrees (off of a shared repository), at least\n> not built-in. It seems like the submodules do set up some sort of bare\n> repository / worktree situation but do not support passing in an\n> existing repository to worktree off of.\n>\n> `--reference` with `--dissociate` does avoid unnecessary fetches on the\n> initial clone, but they do duplicate objects (and without `--dissociate`\n> has all the issues of a non-static shared alternate), and do require\n> duplicate fetches afterwards to update the submodules, even if the\n> central local repository already has everything.\n>\n> Q1: is there any way to massage the submodules into working off of a\n> central shared repository? Poking around and messing with `.git/modules`\n> didn't really work out but I may have just not poked the right bit,\n> having to set up the submodules by hand (or via a bespoke script) is no\n> issue.\n>\n> Q2: is there any chance submodules will gain more first-class support\n> for worktree-ing off of a local repository in the future\n\nDoes this also not work if these are regular, not-bare clones?\n"},{"id":"538727","messageId":"53b70129-7619-4b48-b77f-b7dcc9d4366f@odoo.com","threadId":"65218","inReplyTo":"d8e84ca2-2e86-4cdf-a1db-b6d466677fc3@app.fastmail.com","subject":"Re: git submodule using worktrees?","fromName":"Xavier Morel","fromEmail":"xmo@odoo.com","sentAt":"2026-03-12T08:29:47Z","receivedAt":"2026-03-12T08:29:50Z","isPatch":false,"sender":{"key":"xmo@odoo.com","avatar":"https://gravatar.com/avatar/42b8eb16dcf3bd6c1998698115b36ab6f4d69f93710caa10ff8ab04a9652ae34?d=mp&s=160"},"body":"\nOn 12/03/2026 09:20, Kristoffer Haugsbakk wrote:\n> On Thu, Mar 12, 2026, at 09:13, Xavier Morel wrote:\n>> I have a number of fairly large projects I work with, for that reason I\n>> have a bare clone for each and fork off worktrees as needed in order to\n>> avoid unnecessary duplication and pulls between them. That works just fine.\n>>\n>> However when I tried to use submodules to provide a unified view of some\n>> of those projects I found out that there's seemingly no way to have\n>> submodules created as worktrees (off of a shared repository), at least\n>> not built-in. It seems like the submodules do set up some sort of bare\n>> repository / worktree situation but do not support passing in an\n>> existing repository to worktree off of.\n>>\n>> `--reference` with `--dissociate` does avoid unnecessary fetches on the\n>> initial clone, but they do duplicate objects (and without `--dissociate`\n>> has all the issues of a non-static shared alternate), and do require\n>> duplicate fetches afterwards to update the submodules, even if the\n>> central local repository already has everything.\n>>\n>> Q1: is there any way to massage the submodules into working off of a\n>> central shared repository? Poking around and messing with `.git/modules`\n>> didn't really work out but I may have just not poked the right bit,\n>> having to set up the submodules by hand (or via a bespoke script) is no\n>> issue.\n>>\n>> Q2: is there any chance submodules will gain more first-class support\n>> for worktree-ing off of a local repository in the future\n> \n> Does this also not work if these are regular, not-bare clones?\n\nAs in make worktrees off of non-bare clones? I don't think that would \nmake any difference, to the extent that I tried things out `git \nsubmodule` does not seem to accept a worktree reference (a file with a \n`gitdir:` path) as repository (in `.git/modules`). Although I may have \ninterpreted the error incorrectly.\n"}]}