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

0

u/martinus Sep 17 '26

I've been writing (and rewriting multiple times...) my little project "Git Repo Admin", in short gra, to be able to efficiently work with multiple projects and multiple worktrees.

It basically puts all repositories into a bare clone in a directory (defaults to ~/gra), and gives each worktree a unique 16 letter name. There is no main worktree, no worktree is special. So it looks like this:

~/gra
├── oans
│   ├── .bare        <- the repository itself
│   ├── warmhare     <- a worktree, on main
│   └── goldfish     <- another one, on feature/search
└── nanobench
    ├── .bare
    └── snowwolf

The convenient features that I constantly use are

gra ls         # lists all repos & worktrees
gra cd <name>  # jump to a worktree
gra work       # start/move into a worktree
gra done       # finish up a worktree

I use this extensively with tmux and it makes context switching and working with AI bots very convenient for me.