git worktree ai_generated true

fatal: 'path/to/worktree' is a missing but locked worktree

ID: git/worktree-already-locked

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

A git worktree was previously locked (via git worktree lock) and the directory has since been moved or deleted, but the lock persists. Operations on the worktree fail because git respects the lock even when the worktree path is missing.

generic

Workarounds

  1. 95% success Unlock the worktree then prune or remove it
    Run git worktree unlock <path> to remove the lock, then git worktree remove <path> to cleanly remove it. If the path is missing, use git worktree prune after unlocking.

    Sources: https://git-scm.com/docs/git-worktree

  2. 88% success Manually remove the lock file from .git/worktrees
    Delete the file .git/worktrees/<worktree-name>/locked, then run git worktree prune to clean up the stale entry.

Dead Ends

Common approaches that don't work:

  1. Manually deleting the worktree directory without unlocking it first 80% fail

    The lock metadata in .git/worktrees/<name>/locked persists even after the directory is deleted, preventing git from cleaning up or re-adding the worktree at the same path

  2. Running git worktree prune while the worktree is locked 90% fail

    git worktree prune skips locked worktrees by design, so the stale locked worktree remains in the list

Error Chain

Leads to:
Preceded by:
Frequently confused with: