Skip to Content
Managing Git WorktreesLock a Git Worktree

Lock a Git Worktree

Locking a worktree is a built-in Git protection mechanism that prevents accidental deletion, renaming, relocating, or pruning of critical working directories. WorktreeWise provides an intuitive interface to apply and annotate worktree locks with descriptive human-readable reasons.


When to Lock a Worktree

Consider locking a worktree in scenarios such as:

  • Long-running background tasks: When a worktree is actively compiling a large build, running an extended test matrix, or executing a long-running benchmark.
  • Detached or network storage: When a worktree resides on a network share or removable drive that might temporarily disconnect (preventing git worktree prune from deleting it while offline).
  • Staging & release verification: When an environment must remain strictly unchanged while waiting for QA or deployment sign-off.
  • Experimental spikes: When preserving uncommitted exploratory work that you do not want touched during routine repository maintenance.

How to Lock a Worktree

  1. Open the Worktrees panel and locate the worktree you want to safeguard.
  2. Click the three-dot Actions button.
  3. Select Lock.

Lock action in the worktree menu

  1. In the dialog, enter a clear, descriptive Reason (for example, Preserving release candidate v1.1.0-rc2 for staging smoke tests).
  2. Click Lock.

Lock Worktree with a reason

After confirmation, a lock indicator appears beside the worktree in the sidebar.

Locked worktree status


Protection Guarantees

Once a worktree is locked:

OperationStatus When LockedProtection Guarantee
DeleteDisabledCannot be deleted via the UI or accidental CLI command
RenameDisabledWorktree folder and branch name cannot be modified
MoveDisabledDirectory path cannot be relocated
PruneIgnoredGit and WorktreeWise prune operations completely skip locked entries, even if the folder is temporarily unmounted

Visual Status Indicators

  • A Lock icon (🔒) appears next to the worktree name in the left navigation sidebar.
  • In the Worktree Overview, the worktree receives a distinct Locked tag in its Health summary section, showing the recorded lock reason.