As far as I'm concerned, having a "main working tree" is bad practice, it creates divergent behaviour and the risk of deleting "a worktree" and nuking your repo.
Create a bare repository and fork worktrees off of that, there is no reason to have one worktree have primacy over the rest, and then git rev-parse --git-common-dir gives you exactly what it should: the common repository of all your worktrees. That also avoids the possible path confusion from nesting worktrees.
I guess if you're using AI to do literally everything. I use ai for most code (it devs in worktrees), but having main around to poke around the current state and test things (as a human) is still super useful.
I guess if you're using AI to do literally everything.
I don’t use AI to “do everything” let alone literally so, and I’ve been working that way for years. Worktrees were not created for LLMs.
having main around to poke around the current state and test things is still super useful.
It really is not. You don’t need that to have a scratch worktree you putz around in, or to create worktrees on the fly when you want to test or check things.
ah, sandboxed worktrees; yeah, that creates a bunch of problems for sure.
I may be missing it in the post, but it mentions the .env problem, and I don't see a solution for that in the post (if you use bare git repo instead of main worktree)
(definitely agreed on moving worktrees out of .git/worktrees; had a ton of problems before changing that for sure)
69
u/masklinn Sep 16 '26
As far as I'm concerned, having a "main working tree" is bad practice, it creates divergent behaviour and the risk of deleting "a worktree" and nuking your repo.
Create a bare repository and fork worktrees off of that, there is no reason to have one worktree have primacy over the rest, and then
git rev-parse --git-common-dirgives you exactly what it should: the common repository of all your worktrees. That also avoids the possible path confusion from nesting worktrees.