---
title: "How to remove old git worktrees · Gigamop"
description: "List, check and remove old git worktrees safely, including the ones AI coding agents create per task, then delete their branches."
url: https://gigamop.com/guides/remove-git-worktrees
updated: 2026-10-21
---

# How to remove old git worktrees

3 min read · Updated 21 Oct 2026

## Short answer

```sh
git worktree remove ../repo-my-task
```

Git refuses if the worktree has uncommitted or untracked files, so a clean one is safe to remove. Its branch stays until you delete it.

## 1. List your worktrees

Run it in the main repository. AI coding agents often get one worktree per task, each with its own node_modules and build output, so they add up fast.

```sh
git worktree list
```

## 2. Check for work you haven’t saved

The first command shows uncommitted changes. The second shows commits on the branch that aren’t on any remote yet.

```sh
git -C ../repo-my-task status --short
git log --oneline my-task --not --remotes
```

## 3. Remove it, then its branch

`git branch -d` only deletes a branch that’s already merged.

```sh
git worktree remove ../repo-my-task
git branch -d my-task
```

## 4. Clean up worktrees deleted by hand

If you deleted a worktree folder in Finder, git still lists it. This clears those stale entries.

```sh
git worktree prune
```

## Is it safe?

Both checks protect you: git won’t remove a worktree with uncommitted changes or delete an unmerged branch. `--force` skips them, so use it only when you’re sure. Squash-merged branches look unmerged to git, so check the pull request before forcing.

## Worktrees on our test Mac

- 8 merged worktrees: 3.4 GB
- 1 with uncommitted edits: 1.1 GB
- 1 clean and pushed: 0.57 GB

Gigamop checks each worktree’s git state and never suggests one with uncommitted or unpushed work. [Download Gigamop for Mac](https://gigamop.com/download/latest), free to scan.

## More guides

- [How to clear the npm cache on a Mac](https://gigamop.com/guides/clear-npm-cache)
- [How to delete Docker images on a Mac](https://gigamop.com/guides/delete-docker-images)
- [What’s in System Data on a Mac](https://gigamop.com/guides/mac-system-data)
