stablyai/orca · warning · Error

Worktree is no longer registered with Git but its directory

Error message

Worktree is no longer registered with Git but its directory remains.

What it means

Thrown (ORPHANED_WORKTREE_DIRECTORY_MESSAGE) on the SSH/orphan-safe branch when the worktree is no longer Git-registered, its directory still exists and is proven safe to remove, but args.force is not set. Orca will not auto-delete a proven orphan without explicit force; the error is a prompt for the user to confirm force-delete.

Source

Thrown at src/main/ipc/worktrees.ts:2485

                  (path) => fsProvider.lstat!(path),
                  (path) => fsProvider.readFile(path)
                )
              } else {
                const access = getLocalWorktreePathAccess(localWorktreeGitOptions)
                canCleanOrphanedDirectory =
                  !isDangerousWorktreeRemovalPath(worktreePath, repo.path) &&
                  (await canSafelyRemoveOrphanedWorktreeDirectory(
                    toLocalWorktreeRuntimePath(worktreePath, localWorktreeGitOptions),
                    toLocalWorktreeRuntimePath(repo.path, localWorktreeGitOptions),
                    access.statPath,
                    access.readPath
                  ))
              }
            }
            if (canCleanOrphanedDirectory) {
              assertWorktreeDoesNotContainRegisteredWorktree(worktreePath, registeredWorktrees)
              if (!args.force) {
                throw new Error(ORPHANED_WORKTREE_DIRECTORY_MESSAGE)
              }
              if (repo.connectionId) {
                const removalGate = await runtime.acquireFileWatcherRemoval(
                  worktreePath,
                  repo.connectionId
                )
                let removalCompleted = false
                try {
                  await stopPtysForDestructiveWorktreeRemoval(runtime, args.worktreeId, {
                    connectionId: repo.connectionId,
                    allowUnverifiedStop: args.allowUnverifiedPtyStop
                  })
                  await fsProvider!.deletePath(worktreePath, true)
                  removalCompleted = true
                } finally {
                  await removalGate.finish(removalCompleted)
                }
                await cleanupUnusedWorktreePushTargetRemoteSsh(

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Retry the removal with args.force set to true to clean the orphaned directory.
  2. Confirm the directory is the intended worktree before forcing (the safety check already validates it isn't the repo root or dangerous).
  3. If you do not want Orca to delete it, remove the directory manually and the next remove will take the already-gone path.

Example fix

// before
invoke('worktrees:remove', { worktreeId, force: false })
// after
invoke('worktrees:remove', { worktreeId, force: true })
Defensive patterns

Strategy: retry

Type guard

function isOrphanedDirectoryMessage(e: unknown): boolean {
  return e instanceof Error && e.message.startsWith('Worktree is no longer registered with Git but its directory remains')
}

Try / catch

try {
  await invoke('worktrees:remove', { worktreeId, force: false })
} catch (e) {
  if (isOrphanedDirectoryMessage(e)) {
    // Prompt user, then confirm with force.
    await invoke('worktrees:remove', { worktreeId, force: true })
  } else throw e
}

Prevention

When it happens

Trigger: A worktrees:remove (no force) where Git has deregistered the worktree but the directory remains on disk (or on the SSH host) and passes the safe-orphan checks.

Common situations: An external tool or a prior failed delete deregistered the worktree in Git while leaving the files behind; the directory is now an Orca-tracked orphan.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/73b795cc654f1b01. Report an issue: GitHub.