# Clean up git worktrees on Mac: remove the ones Claude Code, Conductor and Cursor leave behind

> To clean up git worktrees on Mac with Floppy, open Storage in the Library and click Worktrees. Floppy lists every linked worktree by repo with its size and says which are merged. Clean up removes them with git worktree remove and keeps each branch, so Restore brings any back. It never removes one with uncommitted work, unpushed commits, a lock or something running in it. It needs Floppy for Mac 1.21.0.

Floppy 1.68.0, released 2026-11-23. Updated 2026-11-23. https://fpy.sh/changelog/clean-up-git-worktrees-on-mac

## Why do git worktrees take up so much space?

Claude Code, Conductor, Cursor and Codex give each task its own git worktree: a second copy of the repo, checked out on its own branch. Each copy gets its own `node_modules` and build folders, so one worktree of a web app is often 1 to 3 GB.

The worktree stays after the task is done and the PR is merged. Dozens pile up in folders like `.claude/worktrees`, and Finder doesn't show them because they sit in hidden folders.

## How do I clean up git worktrees with Floppy?

1. Open the Library: click Floppy's icon in the Dock.
2. Click **Storage** in the sidebar, or press `⌘4`. Storage finds worktrees while it measures the disk.
3. Under **Suggestions**, **Safe to clear** has a group like **5 worktrees whose PR is merged**, ticked for you. Open it to see each one and why it's merged.
4. Click **Remove them now**, or **Clean up** to remove them along with the caches and the Trash. A note says what went, with **Undo**.
5. Click **Worktrees** in Storage's list to see every worktree by repo. Tick the ones you want gone, or click **Remove** on a row, then **Remove** at the bottom.
6. **Removed lately**, at the bottom of Worktrees, has a **Restore** button on each worktree removed in the last 30 days.

## How does Floppy know a worktree is merged?

Floppy asks GitHub first, then git:

| Where | What it checks | What the row says |
|---|---|---|
| GitHub, through `gh` | The pull request for the branch: merged, or closed without merging | **PR 68 merged 3 days ago.** |
| git | Every commit of the branch is in the default branch | **Its commits are all in main.** |
| git | The branch was squash- or rebase-merged: its change matches a commit on main (`git cherry`, patch-id) | **Squash-merged into main.** |

GitHub is used when the [GitHub CLI](https://cli.github.com) is installed and signed in. Floppy never runs `git fetch` and never changes a remote. A worktree whose PR was closed without merging is never Safe to clear: it shows under **Your call** once it's untouched for the rule's days.

When a worktree was last used is the latest of three things: its last commit, its git index (staging and checkouts) and its newest file outside `node_modules` and build folders. A month-old commit with a file saved this morning counts as used today.

## Which worktrees does Floppy never remove?

These are guarantees, not settings. Floppy checks them during the scan and again just before it removes anything. It never removes a worktree that:

- has uncommitted changes or untracked files (ignored files like `node_modules` don't count);
- has commits that aren't on GitHub or in main;
- has a merge, rebase or cherry-pick halfway through;
- has a process using it, such as Claude Code, a terminal, a dev server or Xcode (checked with `lsof`);
- is locked with `git worktree lock`;
- is the repo's main checkout.

Each kept worktree says why, like **Kept: 3 files not committed.** Removing one runs `git worktree remove` (never `--force`, never a delete by hand), then `git worktree prune`, so git's own list stays right. Worktrees git still lists whose folder is already gone get **Tidy the list**, which runs `git worktree prune`.

## What are the worktree rules in Storage?

Storage › Worktrees has five switches, written as sentences:

| Rule | Starts | What it does |
|---|---|---|
| Remove worktrees whose PR is merged | On | Puts them under Safe to clear, ticked |
| Remove worktrees untouched for 7, 14 or 30 days | On, 14 | Puts unmerged ones under Your call, not ticked |
| For those, clear only node_modules and build folders | Off | Keeps the code and deletes only folders git ignores |
| Also delete the merged local branch | Off | Off keeps the branch, so Restore always works |
| Do this on its own, once a day | Off | Removes merged worktrees only, then sends one notification |

Worktrees Floppy has to keep still give back their `node_modules` once they've sat for the rule's days, under **Your call**, unless something is running in them.

The daily rule is off until you turn it on. The Worktrees page asks once, when it has merged worktrees to show, with the real number. When it's on, Floppy checks the repos it already knows once a day, removes only merged worktrees (never untouched ones), and sends a notification like **Removed 6 merged worktrees, 18.4 GB**.

## Can I bring a removed worktree back?

Yes. Storage › Worktrees lists what was removed in the last 30 days, by you or by the daily rule. **Restore** runs `git worktree add` with the same folder and branch, so the code comes back as it was committed. Run `npm install` again to get its packages.

If you turned on **Also delete the merged local branch**, Restore makes the branch again from its last commit, as long as git still has that commit.

## For AI agents

Worktree cleanup has no MCP tool or API endpoint. It runs on your Mac with your git and gh: the list stays on your Mac, and gh only asks GitHub for each repo's pull requests.

An agent can do the same by hand in a terminal: `git worktree list --porcelain` lists worktrees, `gh pr list --state all --json number,state,headRefName` says which PRs merged, `git status --porcelain` shows uncommitted work, and `git worktree remove <path>` followed by `git worktree prune` removes one. For what agents can do through Floppy's MCP server at `https://fpy.sh/mcp`, see the [agents guide](https://fpy.sh/docs/agents).

## FAQ

### Is it safe to delete the .claude/worktrees folder?

Deleting it by hand leaves git listing worktrees that are gone, and loses any uncommitted work inside. Floppy removes each worktree with git worktree remove instead, and only when it has no uncommitted work, unpushed commits or running process.

### Does Floppy delete my branches?

No, not unless you turn on Also delete the merged local branch. Floppy keeps the branch by default, so Restore can bring the worktree back with git worktree add.

### Does Floppy need the GitHub CLI to clean up worktrees?

No. With gh installed and signed in, Floppy uses each pull request's state. Without it, Floppy uses git: merged into main, squash- or rebase-merged, or no commits of its own.

### Which tools' worktrees does Floppy find?

Any linked git worktree on the disk Storage measures. Floppy names the tool from where it lives: .claude/worktrees for Claude Code, conductor/workspaces for Conductor, .cursor/worktrees for Cursor and .codex/worktrees for Codex.

### Will Floppy remove worktrees without asking?

Only if you turn on Do this on its own, once a day. Then it removes merged worktrees only, checks every guarantee again first, and sends a notification saying what it freed.

## What shipped in 1.68.0

- Floppy for Mac 1.21.0: Storage finds the git worktrees Claude Code, Conductor, Cursor and Codex leave behind, and how big each one is
- Merged ones go under Safe to clear, ones untouched for 7, 14 or 30 days under Your call. Each row says why
- Floppy never removes one with uncommitted work, unpushed commits or something running in it, and keeps the branch so Restore brings it back
- Turn on the daily rule and merged worktrees go on their own, with one notification saying what it freed

## Related

- [Free up storage on Mac](https://fpy.sh/changelog/free-up-storage-on-mac)
- [Floppy for Mac](https://fpy.sh/mac)
- [The Floppy for Mac guide](https://fpy.sh/docs/mac)
- [Worktree cleanup in the changelog](https://fpy.sh/changelog#v1.68.0)
- [Floppy for AI agents](https://fpy.sh/docs/agents)

All releases: https://fpy.sh/changelog · Everything for LLMs: https://fpy.sh/llms.txt
