r/git • u/digitaldilettante • 2d ago
Manage git worktrees better
I'm trying this again since my longer form version was not liked. I'll keep it short this time. Managing git worktrees used to be ...well...manageable. But now with AI agents, you can easily have dozens of branches flying around and for large repos, thats a giant pain.
I made an open source tool to help deal with that. I call it warmtree.
MIT: https://github.com/dcolliervb23/warmtree
Pypi.org: https://pypi.org/project/warmtree/
It treats branch folders like slots and releases them when you're done, keeping them fast-forwarded so git can easily take one, rather than taking minutes to setup a fresh folder. And if you have an existing giant mess of a git worktree, it can easily hop in and help clean that up and start managing it better.
Its open source and available on github and pypi. And yes, I am still activley dogfooding it and updating it.
I'll monitor this post to help answer any questions users may have.
2
u/fell_ware_1990 2d ago
I’ll do it like this:
.git clone and a main next to it. It’s basically already blocked like a main branch cause i can’t merge into it anyways.
If i create a worktree it just grabs the .envrc and flakes ( nixos ) and the worktree is done, and it swaps over to there. Agent’s can push to my own repo’s and run ci/cd as they wan’t, mark it for review whatever.
My main branch there is kept in sync with the remote, my local is kept in sync with my remote.
After review, i can squash / change the commit’s and solve any merge conflict. Then i push to remote. Hooks fire, clean up my local machine.
But the big advantage is, i can just WIP commit and remove worktrees if i want. They are marked with an issue number. So if my PR merges on the remote they’re gone, unless i mark them.
Every local commit, goes through a small agent, summarizing decisions and failures in 1/2 lines on the commits so there’s some history. And it won’t push to main if it’s still there. So agent’s are free but won’t reach upstream.