From: Sergey Organov Date: Wed, 01 Oct 2025 20:22:23 GMT Subject: Re: What is the reason behind not hiding git worktrees from git? Message-ID: <875xcyfk3k.fsf@osv.gnss.ru> In-Reply-To: Junio C Hamano writes: > Ben Knoble writes: > >>> The impact is that the list of worktrees would have to be read to get >>> status. As status is not particularly cheap operation in any case I >>> would expect the problem to be minor. >> >> I believe status information is used for the shell prompt info, so >> performance hits there have a cost. > > Sure, but an embedded git-controlled working tree _should_ be > flagged as an untracked entity, _unless_ it is ignore'd, no? > > That is how you would add a new submodule to your project after all. > So, if you want to ignore them, just add them to .git/info/exclude > or something, perhaps? > > Why do people even want to have such a layout, unless they want to > make it a submodule (or deliberate subdirectory that is unrelated)? > > -+- README.md (your own branch, probably on main) > | > +-+ worktree-foo (worktree checkout of branch foo) > | | > | +-- README.md (a slight variant of the file in foo) > | > +-+ worktree-bar (worktree checkout of branch bar) > | | > | +-- README.md (a slight variant of the file in bar) > | > +-+ worktree-baz (worktree checkout of branch baz) > | | > | +-- README.md (a slight variant of the file in baz) > > Wouldn't it be easier to manage if you had this instead? > > -+ > | > +-+ my-project (the primary worktree, probably on main) > | | > | +-- README.md (the file from branch main) > | > +-+ worktree-foo (worktree checkout of branch foo) > | | > | +-- README.md (a slight variant of the file in foo) > | > +-+ worktree-bar (worktree checkout of branch bar) > | | > | +-- README.md (a slight variant of the file in bar) > | > +-+ worktree-baz (worktree checkout of branch baz) > | | > | +-- README.md (a slight variant of the file in baz) > > That way, you can go up to the umbrella directory and ... > > $ cd .. > $ ls > my-project worktree-foo worktree-bar worktree-baz > $ grep -e HowTo */README.md > > ... do things you would do collectively to these worktrees with the > primary worktree included as well. I suspect people rather expect support for repository with multiple equal worktrees (no "primary" one), like this: myproject / .git / worktree-foo / worktree-bar Also, I'm almost sure that the first thing almost every worktree novice does (I did), quite naturally, is: $ git wotktree add that happily succeeds /anywhere/ inside primary worktree without any warning for me. It probably should either have created $top/../ instead, or refuse to proceed without confirmation in the first place. -- Sergey Organov