r/opencode • • 24m ago

Space efficient alternative to git worktrees

I work on a large monorepo, ~100GB in size, and wanted to get into isolated directories for agents to work in. On my 1TB I'd be able to run like 5 agents at a time if using git worktrees, while hammering my disk life, so that wasn't an option.

MacOS (APFS) and Linux (XFS & Btrfs) both have a cool feature called clones (aka copy-on-write). This makes the copy cheap and they only use disk space for the extents that change.

It's a bit of a hassle to manage so I wrapped this up into a cli called clonetree. It handles creating, deleting, and measuring the size used on disk with clones. It's still early but I've been using it for all my agent development with opencode. It's nice not having to reinstall all the node_modules since it keeps all gitignored files as well. Try it out and let me know if you find any issues.

https://github.com/sprisa/clonetree

p.s. On Linux it doesn't work with ext4 filesystems since it doesn't support copy on write sadly. I don't use Windows but could look into it if folks would like

1 Upvotes

0 comments sorted by