Guide

Git worktrees taking up space, and how to clear them.

Claude Code, Codex, Conductor, and other coding agents give each task its own git worktree. They're quick to make and easy to forget, and every one is a full checkout. Here's how to find them, check what each would lose, and remove them the way git expects.

The short version

Run git worktree list in each repository to see its worktrees, then git worktree remove for the ones you're done with. It refuses a worktree with uncommitted changes. git worktree prune clears git's records of worktree folders that are already gone, which can hold whole copies of every submodule. On the Mac measured here, 36 worktrees in one code folder came to 39 GB.

Why worktrees add up

A worktree is a second checkout of the same repository, on its own branch, sharing the repository's history. The history isn't copied, but everything else is: every tracked file, plus whatever the project installs or builds, like node_modules. Agents make one per task so parallel tasks don't collide, and they rarely clean up after themselves.

Here's one developer Mac in October 2026:

WhatDefault locationOn one Mac
Worktrees in a code folder~/code, made by git worktree add and by agents39 GB, 36 worktrees
Claude Code's worktrees<repository>/.claude/worktreesInside each repository
Git's records of each worktree<repository>/.git/worktrees/<name>8.2 GB for one repository
Submodule copies per worktree<repository>/.git/worktrees/<name>/modules4.1 GB each

The last two rows are easy to miss. Each worktree gets its own folder inside the main repository's .git/worktrees, and if the repository has submodules, every worktree keeps its own copy of each one there. Deleting the worktree's folder in Finder leaves that copy behind.

How to find every worktree

In a repository, git lists its own:

git worktree list

To find worktrees from every repository in a folder, look for the .git file each one has. A normal checkout has a .git folder; a worktree has a one-line file that points back to its repository:

find ~/code -name .git -type f -exec grep -l "gitdir: .*/worktrees/" {} + \
  | sed 's#/.git$##' | tr '\n' '\0' | xargs -0 du -sh | sort -h

Change ~/code to wherever your projects and your agents' worktrees live.

Check what a worktree would lose

The branch and its commits live in the main repository, so removing a worktree doesn't remove them. Two things can still be lost: changes that aren't committed, and commits that were never pushed anywhere else. In the worktree:

git status
git log HEAD --not --remotes --oneline

The first shows changed and untracked files. The second lists commits no remote has. If both are empty, nothing is lost except files git ignores, like .env or a local database, so check for those too.

Remove it the way git expects

git worktree remove ../my-repo-feature
git worktree prune

git worktree remove deletes the folder and git's records of it, including any submodule copies, and refuses if the worktree has uncommitted changes. git worktree prune clears records for worktree folders that were already deleted some other way. Neither touches the branch. Delete that separately with git branch -d once it's merged.

More developer folders that grow on their own: Xcode, node_modules, and Docker, and every tool's cache.

Disk Forecast and git worktrees

Disk Forecast finds worktrees anywhere in your home folder by their .git file and lists them in Cleanup › Worth a look, unchecked, each with its repository, how many files are changed, and how many commits no remote has. Moving one to the Trash also moves git's records of it, like git worktree remove; the branch and its commits stay. Records of worktrees that are already gone are under Safe to clear, except locked ones. It reads git with every program a repository can configure turned off, so looking never runs code from your projects. Its Copy Agent Prompt button hands your picks to Claude Code or Codex with these same checks. It's free.

Questions

Does deleting a git worktree delete the branch?

No. The branch and its commits are in the main repository. Delete the branch separately with git branch -d once it's merged.

Can I just delete a worktree folder in Finder?

It works, but it leaves git's records of the worktree in the repository's .git/worktrees folder, including any submodule copies. Run git worktree prune afterward to clear them.

Where does Claude Code put worktrees?

On the Mac measured here, in each repository's .claude/worktrees folder. Other tools pick their own place, so find worktrees by their .git file rather than by folder name.

Why does git worktree remove refuse?

The worktree has uncommitted changes or untracked files. Commit or stash what you want to keep, or add --force if you're sure nothing in it matters.

Know before it's full.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/diskforecast