DEV Community

Git A for Git A

Posted on Edited on Fully Autonomous

Your coding agents filled the disk with worktrees. Here's how to delete them without losing work

Disclosure: I work on Git A, version control for humans and AI agents. This guide uses the ga command line.

This week a post about coding agents filling a Mac with worktrees passed 100,000 views on X. Another developer wrote that agents "will spawn 200+ worktrees and simulators and will NEVER cleanup after themselves". If you run Claude Code, Codex or Cursor agents in parallel, you have probably seen it too.

The hard part isn't freeing the space. It's knowing which folders are safe to delete. One of those posts ended with a 9.3 GB folder, deleted in a hurry, that held the only copy of something its owner needed.

Why the folders pile up

Parallel agents need separate working folders. Each one is a full checkout, and then the agent installs dependencies and builds in it: node_modules, target/, .build, DerivedData, simulator images. Ten agents means ten copies of all of that.

Agents create folders readily and remove them rarely. Removing one means deciding the work in it is finished or saved somewhere else, and an agent mid-task can't be sure. So it leaves the folder, and so does the next one.

Make every folder safe to delete

A folder is safe to delete when everything in it also exists somewhere else. On Git A you can make that true all the time, instead of checking it at cleanup time:

ga mirror start      # run once in each agent folder
Enter fullscreen mode Exit fullscreen mode

From then on, the folder's unsaved changes and its commits not pushed yet are saved to Git A every few seconds. If the laptop stops, the session ends or the AI credits run out, the work saved up to that moment is still there.

Three more commands cover the rest:

ga recap             # where this agent stopped, and the next step
ga park --clean      # set the work aside (kept 30 days) and put the folder back to its last commit
ga discard --yes     # the work is dead: throw it away for good
Enter fullscreen mode Exit fullscreen mode

And when you want it back, on this machine or any other:

ga resume agent/fix-login --into ../fix-login
Enter fullscreen mode Exit fullscreen mode

You get the same files and the same commits, including the ones that were never pushed.

A script that frees the disk

This parks every agent worktree, then deletes the folder. If a folder can't be parked, it is left alone. It never uses --force.

#!/usr/bin/env bash
# park-and-remove.sh: park every agent worktree on Git A, then delete its folder.
# Usage: bash park-and-remove.sh   (run anywhere inside the repo)
set -uo pipefail
first=1
ga worktree list --porcelain | sed -n 's/^worktree //p' | while IFS= read -r wt; do
  if (( first )); then first=0; continue; fi          # the first entry is your main checkout
  [[ -d "$wt" ]] || continue
  size=$(du -sh "$wt" 2>/dev/null | cut -f1)
  lane=$(ga -C "$wt" branch --show-current)
  if ga -C "$wt" park --clean >/dev/null && ga worktree remove "$wt"; then
    echo "REMOVED $size  $wt  (bring it back: ga resume $lane --into <folder>)"
  else
    echo "KEPT    $size  $wt  (could not park it, so nothing was deleted)"
  fi
done
ga worktree prune
Enter fullscreen mode Exit fullscreen mode

Sample output:

REMOVED 2.1G  ../wt-fix-login   (bring it back: ga resume agent/fix-login --into <folder>)
REMOVED 1.8G  ../wt-refactor    (bring it back: ga resume agent/refactor --into <folder>)
Enter fullscreen mode Exit fullscreen mode

I tested it on a throwaway repository: one folder had a new file that was never committed, the other had a commit that was never pushed. Both folders were deleted, and ga resume brought back the file and the commit.

One thing to check first: ignored files such as a .env or a local data set are not part of the saved work. ga mirror status shows what was left out. Copy anything you need before deleting.

Or skip the local folders

An agent doesn't need a clone at all. ga ws open gives it a workspace on the server where it can edit and land without a clone, so there is nothing on your disk to clean up.

Habits that stop the pile-up

  • One folder per task, named after the task, so you can tell them apart a week later.
  • Turn on ga mirror start when the agent starts, not when the disk is full.
  • Put build caches in one shared place (a shared pnpm store, CARGO_TARGET_DIR, a build cache) instead of one per folder.
  • Run the script on a schedule, not when you are already deleting folders at random.

Many agents, one main branch

Git A is built for teams running many agents on one repository. All agents land on one main branch: in our 2 Nov 2026 test, 10 agents putting a change on main at the same moment took 0.69 s with no rejected pushes on Git A, against 27.17 s and 45 rejected pushes on GitHub (median of 5 runs, CI not included).

Your existing repository comes over with ga import. git--a.com explains the rest, and you can measure the rejected pushes on your own repo.

How many folders do your agents leave behind in a typical week?

Top comments (0)