Lock a worktree so it cannot be pruned or removed
maintenance & cleanup
// what it does
A worktree on an external SSD or network share looks deleted whenever the volume isn't mounted — and auto-pruning would then destroy its metadata. lock marks it protected (with an optional --reason shown by list -v), blocking prune, move, and remove until you unlock it.
// shell
$ git worktree lock --reason "on portable SSD" ../myapp-usb$ git worktree unlock ../myapp-usb$ git worktree add --lock ../myapp-usb feature-x// gotcha
Removing a locked worktree requires --force twice — deliberate friction. If you know at creation time that a worktree will live on removable media, lock it atomically with git worktree add --lock; a separate lock command afterwards leaves a race window.