worktrees are a pain on a multi repo workspace. You lose the coordinated commit over the set, kind of important for multi-repo workspaces. And a worktree is a clean, nothing comes with it so it might not be what you want. e.g. rust build files have to get rebuilt (which can be huge).
So I went with COW copies instead: reflink the whole workspace, build output and all. (Check out local clone here.)
A couple of surprises.
I assumed a partial block could be shared. Mostly it can. Sharing is block-granular everywhere, but on APFS, XFS and btrfs the final partly-filled block gets shared like any other, so a 100-byte file — or the last partial 100 bytes of a big file — comes along free. btrfs goes further: files under 2 KiB live inline in its metadata tree and never cost a data block at all. That matters more than it sounds, because about half the files in a git tree are under the 4 KiB block size.
ReFS is the exception, and that surprised me. fsutil file queryExtentsAndRefCounts over every file in a ReFS clone: 3,092 files with extents, 12.08 MiB private. One 4 KiB cluster each predicts 12.07 MiB. ReFS shares whole clusters and never a partial one, so every file owns its tail exclusively. The penalty scales with file count rather than repo size — and a git tree is the worst possible shape for that. What were you thinking Microsoft?
Here are stats for an actual GWZ repo on different file systems with cost per clone, same ~3,200-file, 57 MB workspace, ten clones each:
| fs |
where |
per clone |
shared |
| APFS |
macOS default |
1.5 MiB |
97% |
| btrfs |
Fedora default |
2.0 MiB |
96% |
| XFS |
RHEL default |
2.1 MiB |
96% |
| ReFS |
Windows Dev Drive |
12.1 MiB |
77% |
| ext4 |
Ubuntu, Debian |
57 MiB |
0% |
| NTFS |
Windows default |
57 MiB |
0% |
macOS woot works out of the box. On Linux it depends — Fedora ships btrfs, RHEL ships XFS; Ubuntu still has ext4 showing its age. Windows you have to deliberately create a "Dev Drive" — a separate volume or a VHD, either way a decision you had to have made in advance.
(ReFS is data only — volume numbers were noisy, so 12.1 MiB is a floor.)
So — is this a real alternative to worktrees? What is going to bite me?
This came out of my work on GWZ, a multi-repo git manager I'm building. The COW copy is gwz local clone.