Skip to content
WorktreeWise
Git Worktree CommandStep #3

git worktree remove: Safely Delete a Git Worktree

The git worktree remove command safely removes a linked worktree directory from your filesystem and unregisters its administrative metadata in the primary repository.

Basic Syntax

Terminal
# Remove a worktree by relative path or directory name
$git worktree remove <worktree>

For example, to remove a finished feature worktree:

Terminal
# Deletes the folder and unregisters worktree metadata
$git worktree remove ../project-feature-auth
BEFORE git worktree remove
projects/
├── project/              [main]
└── project-feature-auth/ [feature/auth]
AFTER git worktree remove
projects/
└── project/              [main]
(project-feature-auth folder deleted)

Important: Removing a worktree does NOT delete its Git branch

When you execute git worktree remove, Git deletes the working directory folder from disk and cleans the worktree registry. Your Git branch (feature/auth) remains completely intact in the repository history!

You can verify that your branch is still safe:

Terminal
# Branch still exists in Git object database
$git branch --list 'feature/*'
Output Example
* main
  feature/auth

If you also want to delete the Git branch after merging, run git branch -d feature/auth separately.

Protection Against Uncommitted Changes

If you have modified tracked files or uncommitted changes inside the worktree, Git intentionally blocks removal to prevent data loss:

Git Safety Error
fatal: 'project-feature-auth' contains modified or untracked files, use --force to delete it

How to resolve:

  • Option A (Recommended): Navigate into the folder, inspect changes with git status, and commit or discard them intentionally.
  • Option B (Force Deletion): If you are certain you want to discard all untracked files and changes, use the force flag:
Terminal
# Forces removal and deletes uncommitted modifications
$git worktree remove --force ../project-feature-auth

Removing Locked Worktrees

If a worktree was protected with git worktree lock, Git will refuse standard removal. You must first unlock it with git worktree unlock or supply double force --force --force.

Standard Post-Merge Cleanup Workflow

Terminal
# Complete clean post-merge routine
$# 1. Inspect all worktrees git worktree list # 2. Remove the merged worktree directory git worktree remove ../project-feature-auth # 3. Delete the local branch (now that PR is merged) git branch -d feature/auth
WorktreeWise

Delete Worktree

Try Free

WorktreeWise checks for uncommitted changes before deletion and gives you the option to keep or delete the associated Git branch simultaneously from one visual dialog.

Delete a Git worktree safely with confirmation in WorktreeWise

Related commands

If the worktree folder was already deleted through your operating system file manager, use git worktree prune instead to clean up stale administrative records.