wt

wt remove

Remove a git worktree cleanly, checking for uncommitted changes first.

Synopsis

wt remove <branch> [options]

Description

wt remove removes a git worktree cleanly. It checks for uncommitted changes before proceeding and optionally deletes the associated git branch.

Arguments

ArgumentDescription
<branch>Branch name or partial match. "feat" matches "shreyansh/feat-billing"

Options

OptionDescription
--forceRemove even if there are uncommitted changes; also force-deletes the branch (-D instead of -d)
--keep-branchRemove the worktree but keep the git branch

Behaviour

  1. Find the worktree by branch name (exact or partial match)
  2. Check for uncommitted changes — abort unless --force
  3. Run git worktree remove
  4. Delete the git branch with git branch -d (unless --keep-branch)

Examples

wt remove feat-billing
wt remove feat-billing --keep-branch   # preserve the branch for later
wt remove feat-billing --force         # discard uncommitted changes

Exit Codes

CodeMeaning
0Success
1Error
2Partial success (worktree removed but branch deletion failed)

On this page