tutorial Coding agents create branches and worktrees. Who cleans them up?
One of the things I encountered when I was working on my AI harness was the sheer number of branches and worktrees that were getting created, and how tools like go-git started struggling
I wrote this article/video on how I worked around it.
TLDR:
- clean up your branches
- pack your git objects
- and write some tooling in your system so you actively maintain this
0
Upvotes
1
u/elephantdingo Oct 12 '26
These fake problems are getting stupider by the day.
1
u/Ok_Produce3836 Oct 13 '26
Me :)
https://maciej-ciemborowicz.eu/articles/brunch_isolated_development_environments
3
u/GoTeamLightningbolt Oct 11 '26
I do when the OS gives me the "running out of disk space" warning lol
2
u/The_Northern_Light Oct 11 '26
I just have a cron job that cleans up any old / inactive worktrees without uncommitted changes.
Naturally, the agent wrote this for me too.
1
u/jjangg96 Oct 11 '26
one thing that bit me with cleanup scripts. if you squash merge prs, git branch --merged and merge-base --is-ancestor say almost every branch is unmerged, even though the content is already in main.
i ended up checking pr state with gh pr list --state all --json headRefName,state and only trusting that. also git status --porcelain in each worktree before removing it, a couple of mine had files that were never committed anywhere.
i had 31 agent worktrees and about 30gb before i even noticed.
1
u/waterkip detached HEAD Oct 11 '26
you call the agent, so you?
1
u/Sulungskwa Oct 11 '26
username checks out. fuck you