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

Re: [PATCH] worktree: allow sharing root files with linked worktrees

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Nov 30, 2026, 16:08 UTC
Message-ID
<CALnO6CAX0hNzQ5t99wTwvbrruH5XCu3mbOAM6vdy4ZLMRHWdcg@mail.gmail.com>
In-Reply-To
<pull.2245.git.1795717517830.gitgitgadget@gmail.com>

See also https://lore.kernel.org/git/CAA8YNQAsyUe275DLPRnB4dym5aq9ZyemA39u+HJciKzat5tNQA@mail.gmail.com/, perhaps?

On Thu, Nov 26, 2026 at 1:25 PM Bhushan Gaikwad via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 15 quoted lines
>
> From: Bhushan Gaikwad <bhushan@alfredscholar.com>
>
> Ignored configuration files such as .env often need to remain identical
> across linked worktrees. Today users must copy them manually or install a
> post-checkout hook, which is easy to forget and can create divergent local
> configuration.
>
> Add a multi-valued worktree.sharedFile setting. For each configured
> root-level regular file, worktree add creates an absolute symbolic link
> from the new worktree to the primary worktree before running the
> post-checkout hook.
>
> Reject nested paths and source symlinks, avoid replacing checkout files,
> and fail cleanly when symbolic links are unavailable.
The limitations and design choices seem odd to me:

• On what platforms do we not support symlinks? Wikipedia suggests Windows has equivalents, but our mingw compatibility layer says they are disabled unless MSYS contains winsymlinks:nativestrict, and of course I don't know what other platforms do to customize the build. • Why reject nested paths? A project at work has api/.env{,.example} which might benefit. • Why use absolute symlinks? I suppose that might be annoying when a directory might have a different absolute path on different machines (due to NFS or something)? Is it a security thing, something about relative symlinks becoming a nice target for some kind of exploit?

I wonder if instead we could just copy the paths, which lets them diverge (in case a worktree wants differing settings!), though at risk of forgetting the divergence in a long-lived worktree?

I am somewhat negative on making Git do this automatically, personally, especially since the example ".env" is typically ignored (i.e., not managed by Git at all). But that's just my opinion, so if the design is fleshed out and others are positive, ok.

-- 
D. Ben Knoble
Previous: Bhushan Gaikwad via GitGitGadgetNext: Bhushan Gaikwad
Message 2 of 5 in “worktree: allow sharing root files with linked worktrees”
  1. worktree: allow sharing root files with linked worktreesBhushan Gaikwad via GitGitGadget, Nov 26, 2026
  2. D. Ben KnobleNov 30, 2026
  3. Bhushan GaikwadDec 1, 2026
  4. Eric SunshineDec 1, 2026
  5. Patrick SteinhardtDec 1, 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.