# Git Worktree Prune or Remove: Delete a Worktree Cleanly

_Use `git worktree remove` to delete a worktree you still have. Use `git worktree prune` to clean up after a worktree folder you already deleted._

## The Fix

Delete a worktree and its directory, then its branch if you no longer need it:

```bash
git worktree remove ../repo-feature
git branch -d feature
```

If you already ran `rm -rf` on the folder, Git still lists it as `prunable`:

```text
/src/repo       54d33c8 [main]
/src/quick-fix  54d33c8 [quick-fix] prunable
```

Preview the cleanup, then run it:

```bash
git worktree prune --dry-run -v
git worktree prune -v
```

```text
Removing worktrees/quick-fix: gitdir file points to non-existent location
```

## Remove vs Prune

| | `git worktree remove ` | `git worktree prune` |
|---|---|---|
| Use when | The worktree directory still exists | The directory is already gone |
| Deletes the directory | Yes | No, there is nothing left to delete |
| Deletes the record in `.git/worktrees/` | Yes | Yes, for every missing worktree |
| Deletes the branch | No | No |
| Skips locked worktrees | Yes, unless you pass `-f` twice | Yes |

Neither command deletes the branch. After a prune, `git branch --list quick-fix` still shows `quick-fix`. Delete it with `git branch -d`, or `-D` if it has unmerged commits.

`git gc` also prunes stale worktree records once they are older than `gc.worktreePruneExpire`, which defaults to three months. Run `git worktree prune` when you want the entry gone now.

## Why It Fails

`remove` refuses a worktree with uncommitted work:

```text
fatal: '../repo-feature' contains modified or untracked files, use --force to delete it
```

Commit or copy what you need, then add `--force`. A locked worktree needs `git worktree unlock` first, or `-f -f`. [Remove a locked Git worktree](./remove-locked-worktree.md) covers that case. `remove` also refuses the main worktree with `fatal: '.' is a main working tree`.

If you moved a worktree folder instead of deleting it, Git marks the old path `prunable` too. Do not prune it. Run `git worktree repair ` to reconnect it.

## How Treq Handles It

Deleting a [workspace](/docs/concepts/workspaces) in Treq drops the workspace, its directory and its local metadata in one step. There is no stale entry to prune afterward. See [Managing Workspaces](/docs/tutorials/managing-workspaces).

## Related

- [Remove a locked Git worktree](./remove-locked-worktree.md)
- [How to use git worktree add](./git-worktree-add.md)
- [What are Git Worktrees?](/learn/concepts/git/git-worktrees)
