Appearance
git worktree-prune
Remove worktrees and branches for deleted remote branches
TIP
This command is also available as daft prune. See daft prune.
Description
Removes local branches whose corresponding remote tracking branches have been deleted, along with any associated worktrees. This is useful for cleaning up after branches have been merged and deleted on the remote.
The command first fetches from the remote with pruning enabled to update the list of remote tracking branches. It then identifies local branches that were tracking now-deleted remote branches, removes their worktrees (if any exist), and finally deletes the local branches.
If you are currently inside a worktree that is about to be pruned, the command handles this gracefully. In a bare-repo worktree layout (created by daft), the current worktree is removed last and the shell is redirected to a safe location (project root by default, or the default branch worktree if configured via daft.prune.cdTarget). In a regular repository where the current branch is being pruned, the command checks out the default branch before deleting the old branch.
Pre-remove and post-remove lifecycle hooks are executed for each worktree removal if the repository is trusted. See git-daft(1) for hook management.
Usage
git worktree-prune [OPTIONS]Options
| Option | Description | Default |
|---|---|---|
-v, --verbose | Increase verbosity (-v for hook details, -vv for full sequential output) | |
-f, --force | Force removal of worktrees with uncommitted changes or untracked files | |
--stat <STAT> | Statistics mode: summary or lines (default: from git config daft.prune.stat, or summary) | |
--columns <COLUMNS> | Columns to display (comma-separated). Replace: branch,path,age. Modify defaults: +col,-col. Available: branch, path, size, base, changes, remote, age, annotation, owner, hash, last-commit | |
--sort <SORT> | Sort order (comma-separated). +col ascending, -col descending. Columns: branch, path, size, base, changes, remote, age, owner, hash, activity, commit |
Global Options
| Option | Description |
|---|---|
-h, --help | Print help information |
-V, --version | Print version information |