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

Re: [PATCH v2 0/2] worktree: copy-on-write creation and ephemeral branches

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 21, 2026, 07:08 UTC
Message-ID
<CAPig+cRtMkJb6Y-b9M8JP5pmZXuHZf7Y+3-0mFVP2N4Zd+KpjA@mail.gmail.com>
In-Reply-To
<pull.2317.v2.git.git.1792512249.gitgitgadget@gmail.com>

On Tue, Oct 20, 2026 at 12:08 PM Jason Newton via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 20 quoted lines
> 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/
Previous: Jason NewtonNext: Jason Newton via GitGitGadget
Message 18 of 23 in “worktree: copy-on-write creation and shared-branch worktrees”
  1. 0/2 worktree: copy-on-write creation and shared-branch worktreesJason Newton via GitGitGadget, Jun 5, 2026
  2. 1/2 worktree: add --reflink for copy-on-write worktree creationJason Newton via GitGitGadget, Jun 5, 2026
  3. 2/2 worktree: allow sharing a checked-out branch across worktreesJason Newton via GitGitGadget, Jun 5, 2026
  4. brian m. carlsonJun 5, 2026
  5. Junio C HamanoJun 8, 2026
  6. 0/2 worktree: copy-on-write creation and ephemeral branchesJason Newton via GitGitGadget, Oct 20, 2026
  7. 1/2 worktree: add --reflink for copy-on-write worktree creationJason Newton via GitGitGadget, Oct 20, 2026
  8. brian m. carlsonOct 20, 2026
  9. Jason NewtonOct 21, 2026
  10. brian m. carlsonOct 22, 2026
  11. 2/2 worktree: reap ephemeral branches created by "worktree add"Jason Newton via GitGitGadget, Oct 20, 2026
  12. Eric SunshineOct 21, 2026
  13. Jason NewtonOct 21, 2026
  14. Eric SunshineOct 21, 2026
  15. Jason NewtonOct 21, 2026
  16. Phillip WoodOct 21, 2026
  17. Jason NewtonOct 21, 2026
  18. Eric SunshineOct 21, 2026
  19. 0/4 worktree: copy-on-write creation and ephemeral branchesJason Newton via GitGitGadget, Oct 21, 2026
  20. 1/4 worktree: add --reflink for copy-on-write worktree creationJason Newton via GitGitGadget, Oct 21, 2026
  21. 2/4 worktree: reap ephemeral branches created by "worktree add"Jason Newton via GitGitGadget, Oct 21, 2026
  22. 3/4 worktree: disable reflink on WindowsJason Newton via GitGitGadget, Oct 21, 2026
  23. 4/4 worktree: keep the reflink probe referenced on WindowsJason Newton via GitGitGadget, Oct 21, 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.