Subject: Re: What is the reason behind not hiding git worktrees from git?

From: Michal Suchánek <[email-masked]>
Date: Tue, 30 Sep 2025 12:30:42 +0200

On Sat, Sep 27, 2025 at 09:26:54PM +0000, Jason Cho wrote:
> I think the best practice is to not add a work tre within the master work tree.

And is that best practice documented somewhere?

IIRC there are some VCSs for which it is common practice to keep
checkouts of multiple branches side by side in the repository directory.
IIRC the repository directory itself is not a checkout in this case.
Anyway, there is no obvious reason for anyone not familiar with git
internals to not do this.

> Suppose a repo is at the master branch, and you export a work tree in the directory f.
> 
> Then, you check out the main repo to another branch which so happens to have a file named f. In this case, the check-out will fail due to the name collision.

That would not happen in this work style, each branch has a separate
checkout. If you want to checkout a branch you create a worktree for it.

Thanks

Michal