{"record":{"id":"a71a3ace60e3c148","repo":"coleam00/Archon","slug":"warning-worktree-existingenv-branch-name-is","errorCode":null,"errorMessage":"Warning: Worktree '${existingEnv.branch_name}' is not based on '${configuredBase}'. Recreate with: bun run cli complete ${existingEnv.branch_name} --force","messagePattern":"Warning: Worktree '(.+?)' is not based on '(.+?)'\\. Recreate with: bun run cli complete (.+?) --force","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2647,"sourceCode":"        if (flagBase) {\n          configuredBase = git.toBranchName(flagBase);\n        } else if (rawBase) {\n          configuredBase = git.toBranchName(rawBase);\n        } else if (codebaseDefaultBranch) {\n          configuredBase = git.toBranchName(codebaseDefaultBranch);\n        } else {\n          configuredBase = await git.getDefaultBranch(git.toRepoPath(codebase.default_cwd));\n        }\n        const isValidBase = await git.isAncestorOf(\n          git.toWorktreePath(existingEnv.working_path),\n          `origin/${configuredBase}`\n        );\n        if (!isValidBase) {\n          getLog().warn(\n            { path: existingEnv.working_path, configuredBase, branch: existingEnv.branch_name },\n            'worktree.reuse_base_branch_mismatch'\n          );\n          console.warn(\n            `Warning: Worktree '${existingEnv.branch_name}' is not based on '${configuredBase}'. ` +\n              `Recreate with: bun run cli complete ${existingEnv.branch_name} --force`\n          );\n        }\n      } catch (e) {\n        getLog().debug({ err: e }, 'worktree.reuse_base_branch_check_skipped');\n        // Non-blocking — skip warning if base branch cannot be determined\n      }\n      getLog().info({ path: existingEnv.working_path }, 'worktree_reused');\n      workingCwd = existingEnv.working_path;\n      isolationEnvId = existingEnv.id;\n    } else {\n      // Create new worktree\n      getLog().info(\n        { branch: branchIdentifier, fromBranch: options.fromBranch },\n        'worktree_creating'\n      );\n","sourceCodeStart":2629,"sourceCodeEnd":2665,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2629-L2665","documentation":"Warning from the run precheck (packages/cli/src/commands/workflow.ts:2647), logged as 'worktree.reuse_base_branch_mismatch'. An existing worktree is being reused, but its branch was not cut from the currently configured base branch (e.g. the project's configured base changed, or the worktree is stale). Archon proceeds but warns, and tells you the exact command to recreate the environment.","triggerScenarios":"Reusing an existing worktree whose merge-base with `configuredBase` fails the validity check (`isValidBase` false) — typically after changing the configured base branch or after the base was rebased/reset.","commonSituations":"Team switched default branch from `main` to `develop` while old worktrees exist; base branch history rewritten; worktree created long ago from an ancestor commit no longer considered a valid base.","solutions":["Recreate the worktree as the warning instructs: `bun run cli complete <branch> --force`, then re-run the workflow.","Or update your configuration so `configuredBase` matches what the worktree was actually cut from.","If the mismatch is intentional (long-lived worktree), acknowledge and continue — the run is not blocked.","Inspect the branch ancestry (`git merge-base`) to confirm the relationship before ignoring."],"exampleFix":"// before: worktree cut from main, config now says develop\narchon workflow run fix   # Warning: not based on 'develop'\n// after\nbun run cli complete feat/fix --force\narchon workflow run fix","handlingStrategy":"validation","validationCode":"// Verify the worktree base before reusing it\nconst base = execSync(`git -C ${worktree} merge-base HEAD ${configuredBase}`).toString().trim();\nconst head = execSync(`git -C ${worktree} rev-parse HEAD`).toString().trim();\nconst valid = base === head || isAncestor(base, head); // mirror the CLI's validity check","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Recreate worktrees after changing the configured base branch.","Avoid history rewrites on the base branch, or expect to recreate environments.","Periodically prune stale worktrees with `archon isolation complete <branch> --force`."],"tags":["cli","git-worktree","branch-base","stale-environment"],"backgroundTag":"stale-worktree-base-mismatch","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}