{"record":{"id":"948df55d2fd8b3e5","repo":"GitoxideLabs/gitoxide","slug":"is-checked-out-in-another-worktree","errorCode":null,"errorMessage":"{} is checked out in another worktree","messagePattern":"(.+?) is checked out in another worktree","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/time_travel.rs","lineNumber":705,"sourceCode":"        {\n            continue;\n        }\n        ensure_worktree_does_not_own_branch(\n            proxy\n                .into_repo_with_possibly_inaccessible_worktree()\n                .context(\"could not inspect a linked worktree while checking the remembered branch\")?,\n            branch,\n        )?;\n    }\n    Ok(())\n}\n\nfn ensure_worktree_does_not_own_branch(worktree: gix::Repository, branch: &gix::refs::FullNameRef) -> Result<()> {\n    let head = worktree\n        .head()\n        .context(\"could not inspect another worktree HEAD while checking the remembered branch\")?;\n    if head.referent_name() == Some(branch) {\n        anyhow::bail!(\"{} is checked out in another worktree\", branch.shorten());\n    }\n    Ok(())\n}\n\npub(crate) fn perform(\n    repository_path: &Path,\n    bare: bool,\n    selected: ObjectId,\n    graph: &history::HistoryGraph,\n    review_roots: &[ObjectId],\n    revisions: &[OsString],\n    include_worktrees: bool,\n) -> Result<Perform> {\n    perform_reporting_rebased(\n        repository_path,\n        bare,\n        selected,\n        graph,","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/time_travel.rs#L687-L723","documentation":"The branch that should be made available is currently checked out in another worktree of the same repository. Git forbids two worktrees having the same branch checked out, so the library's `ensure_worktree_does_not_own_branch` bails when a linked worktree's HEAD referent matches the branch. Attaching/creating that branch ref would violate git's worktree rules.","triggerScenarios":"Calling ensure_branch_is_available (e.g. during attach or perform) while a linked worktree exists whose HEAD symbolic name equals the target branch, detected via `head.referent_name() == Some(branch)`.","commonSituations":"Developers using `git worktree add` for parallel work; CI sharing a repo directory; the branch left checked out in a stale worktree directory that was never pruned.","solutions":["Remove or detach the conflicting worktree: `git worktree remove <path>` or `git -C <path> checkout --detach`.","Run `git worktree prune` to clean up stale worktree metadata if the directory is gone.","Pick a different branch name for the remembered state.","List worktrees with `git worktree list` to find which one holds the branch."],"exampleFix":"$ git worktree list\n/tmp/wt  1a2b3c4 [feature]  # offending\n$ git worktree remove /tmp/wt","handlingStrategy":"validation","validationCode":"for wt in repo.worktrees()?.iter() {\n    if let Ok(head) = wt.repository().head() {\n        if head.referent_name() == Some(branch) {\n            return Err(anyhow!(\"branch in use by worktree\"));\n        }\n    }\n}","typeGuard":"fn branch_is_free(repo: &gix::Repository, branch: &gix::refs::FullNameRef) -> bool {\n    repo.worktrees()\n        .map(|wts| {\n            wts.iter().all(|wt| {\n                wt.repository()\n                    .ok()\n                    .and_then(|r| r.head().ok())\n                    .and_then(|h| h.referent_name().map(|n| n != branch))\n                    .unwrap_or(true)\n            })\n        })\n        .unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"checked out in another worktree\") => {\n        eprintln!(\"run `git worktree list` and remove/detach the conflicting worktree\");\n    }\n    other => other?,\n}","preventionTips":["Run `git worktree list` before claiming a branch.","Prune stale worktrees (`git worktree prune`) as repo hygiene.","Detach or remove linked worktrees when they are no longer needed.","Use unique branch names per worktree to avoid collisions."],"tags":["git","worktree","branch-conflict","checkout"],"backgroundTag":"resource-conflict","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}