{"thread":{"id":"63944","subject":"Git synthetic worktree","startedAt":"2025-08-12T07:55:46Z","lastAt":"2025-08-12T13:47:39Z","messageCount":2,"participants":["Jimmy Thrasibule","Antonio Russo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"524017","messageId":"CAMqSRmCj-wcra=HE1=kv1LQU3UxhBg6zfbtO_OhWwJEqdf8gmw@mail.gmail.com","threadId":"63944","inReplyTo":null,"subject":"Git synthetic worktree","fromName":"Jimmy Thrasibule","fromEmail":"jimmy.thrasibule@gmail.com","sentAt":"2025-08-12T07:56:11Z","receivedAt":"2025-08-12T07:55:46Z","isPatch":false,"sender":{"key":"jimmy.thrasibule@gmail.com","avatar":null},"body":"Hi,\n\nI'd like to create a single worktree where files from multiple Git\nrepositories (or refs) coexist side-by-side (no subfolder separation),\nbut each with repository still independently tracked by Git.\n\nThere may be multiple uses cases such as vendoring where a child\nproject constructs a synthetic worktree with all its dependencies.\nAnother use case is to generate patches with a tool such as `Quilt\n<https://savannah.nongnu.org/projects/quilt>` where the ``patches``\nfolder is an independent repository.\n\nFor example:\n\n```\nPROJECT A\n├ File A\n├ File B\n└ README\n```\n\n```\nPROJECT B\n├ patches\n│ ├ File 1\n│ └ File 2\n└ README\n```\n\n```\nSYNTHETIC\n├ patches\n│ ├ File 1\n│ └ File 2\n├ File A\n├ File B\n└ README\n```\n\nTo put it simply, I'd like to replicate `Overlay FS\n<https://docs.kernel.org/filesystems/overlayfs.html>` in Git.\n\nNow what happens when we have the same file in the repositories? We\ncan specify which repository is at the top of the stack.\n\nThe CLI experience could look like something like this:\n\n```\n$ git clone repoA\n$ git remote add repoB\n$ git worktree push repoB/main\nUsual git commands now applies to `repoB`.\n$ git worktree top repoA.\nUsual git commands now applies to `repoA`.\n$ git worktree pop repoB/main\nFiles from `repoB` are gone.\n```\n"},{"id":"524037","messageId":"b6179ded-abbf-4c9a-95c4-903451f7bc71@aerusso.net","threadId":"63944","inReplyTo":"CAMqSRmCj-wcra=HE1=kv1LQU3UxhBg6zfbtO_OhWwJEqdf8gmw@mail.gmail.com","subject":"Re: Git synthetic worktree","fromName":"Antonio Russo","fromEmail":"aerusso@aerusso.net","sentAt":"2025-08-12T13:40:55Z","receivedAt":"2025-08-12T13:47:39Z","isPatch":false,"sender":{"key":"aerusso@aerusso.net","avatar":"https://avatars.githubusercontent.com/u/6502699?v=4"},"body":"On 2025-08-12 01:56, Jimmy Thrasibule wrote:\n> Hi,\n> \n> I'd like to create a single worktree where files from multiple Git\n> repositories (or refs) coexist side-by-side (no subfolder separation),\n> but each with repository still independently tracked by Git.\n\nI've accomplished something similar to this with a gitignore-everything\npolicy and sparse checkout (non-cone mode, very important!).\n\nIt's janky: I use GIT_DIR and GIT_WORK_TREE to force the selection of\nwhich git repository, and I have to use 'git add -f' everywhere.\n\nIf you need something that works today, this may be a workaround.  It\ndoes not allow for your \"default override\" based on layer priority,\ninstead it is very file-by-file specific.\n\nAs an aside, what you are describing sounds somewhat like a use-case\nfor ostree, which I know very little about.\n\nBest,\nAntonio\n"}]}