{"record":{"id":"73b795cc654f1b01","repo":"stablyai/orca","slug":"worktree-is-no-longer-registered-with-git-but-its","errorCode":null,"errorMessage":"Worktree is no longer registered with Git but its directory remains.","messagePattern":"Worktree is no longer registered with Git but its directory remains\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ipc/worktrees.ts","lineNumber":2485,"sourceCode":"                  (path) => fsProvider.lstat!(path),\n                  (path) => fsProvider.readFile(path)\n                )\n              } else {\n                const access = getLocalWorktreePathAccess(localWorktreeGitOptions)\n                canCleanOrphanedDirectory =\n                  !isDangerousWorktreeRemovalPath(worktreePath, repo.path) &&\n                  (await canSafelyRemoveOrphanedWorktreeDirectory(\n                    toLocalWorktreeRuntimePath(worktreePath, localWorktreeGitOptions),\n                    toLocalWorktreeRuntimePath(repo.path, localWorktreeGitOptions),\n                    access.statPath,\n                    access.readPath\n                  ))\n              }\n            }\n            if (canCleanOrphanedDirectory) {\n              assertWorktreeDoesNotContainRegisteredWorktree(worktreePath, registeredWorktrees)\n              if (!args.force) {\n                throw new Error(ORPHANED_WORKTREE_DIRECTORY_MESSAGE)\n              }\n              if (repo.connectionId) {\n                const removalGate = await runtime.acquireFileWatcherRemoval(\n                  worktreePath,\n                  repo.connectionId\n                )\n                let removalCompleted = false\n                try {\n                  await stopPtysForDestructiveWorktreeRemoval(runtime, args.worktreeId, {\n                    connectionId: repo.connectionId,\n                    allowUnverifiedStop: args.allowUnverifiedPtyStop\n                  })\n                  await fsProvider!.deletePath(worktreePath, true)\n                  removalCompleted = true\n                } finally {\n                  await removalGate.finish(removalCompleted)\n                }\n                await cleanupUnusedWorktreePushTargetRemoteSsh(","sourceCodeStart":2467,"sourceCodeEnd":2503,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L2467-L2503","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the removal with args.force set to true to clean the orphaned directory.","Confirm the directory is the intended worktree before forcing (the safety check already validates it isn't the repo root or dangerous).","If you do not want Orca to delete it, remove the directory manually and the next remove will take the already-gone path."],"exampleFix":"// before\ninvoke('worktrees:remove', { worktreeId, force: false })\n// after\ninvoke('worktrees:remove', { worktreeId, force: true })","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isOrphanedDirectoryMessage(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Worktree is no longer registered with Git but its directory remains')\n}","tryCatchPattern":"try {\n  await invoke('worktrees:remove', { worktreeId, force: false })\n} catch (e) {\n  if (isOrphanedDirectoryMessage(e)) {\n    // Prompt user, then confirm with force.\n    await invoke('worktrees:remove', { worktreeId, force: true })\n  } else throw e\n}","preventionTips":["Prompt the user to confirm force-delete when an orphaned directory is detected.","Avoid leaving directories behind after out-of-band `git worktree remove`.","Use force only after the safety check has validated the path."],"tags":["worktree-remove","orphan-cleanup","force-delete","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}