From: Eric Sunshine Date: Wed, 21 Oct 2026 07:08:18 GMT Subject: Re: [PATCH v2 0/2] worktree: copy-on-write creation and ephemeral branches Message-ID: In-Reply-To: On Tue, Oct 20, 2026 at 12:08 PM Jason Newton via GitGitGadget wrote: > When many worktrees share one repository -- for example a fleet of agents > each needing an isolated checkout -- "git worktree add" is costly at scale. > Objects are shared via the common directory, but the working tree is not: > each add rewrites every tracked file, so N worktrees cost N full checkouts > of disk and I/O. A branch created only to back one of those worktrees is > also left behind when the worktree is removed. > > Patch 1 adds "git worktree add --reflink". On a copy-on-write filesystem it > populates the new worktree by reflinking the current worktree's files and > index, then "git reset --hard" rewrites only the paths that differ from . > reflink_file() in copy.c uses FICLONE (Linux), clonefile() (macOS), and ReFS > block cloning (FSCTL_DUPLICATE_EXTENTS_TO_FILE, as Git LFS does). Elsewhere > it is probed up front and falls back to a normal checkout. worktree.reflink > (true/false/auto) sets the default; --no-reflink overrides. > > Changes since v1: > [...] > * Kept --reflink opt-in. A whole-tree reflink is not invisible: it carries > untracked files, and cloning every file can be slower than checkout when > the files are small (Junio; qub1n on the ReFS work). I may be missing something, but it's still not clear from this explanation why --reflink must be opt-in rather than default behavior. The above only seems to be touching on Junio's superficial "cp treeA treeB" example[*], but doesn't answer the deeper question he asked about why this can't be the default behavior for individual tracked resources in the worktree (his "a_hash at a_path" example). [*]: https://lore.kernel.org/git/xmqq8q8pxfny.fsf@gitster.g/