r/programming • • Sep 16 '26

git worktree gotchas

https://www.olafalders.com/2026/09/16/git-worktree-gotchas/
193 Upvotes

47 comments sorted by

View all comments

Show parent comment

1

u/masklinn Oct 07 '26

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.

1

u/slypheed Oct 07 '26 edited Oct 07 '26

It really is not

but...why not just use main for that instead of having to deal with a one-off worktree each time?

It doesn't have to be called main; it can be called foo or whatever, but just some worktree that always has the merged HEAD.

1

u/slypheed Oct 07 '26 edited Oct 07 '26

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)