{"record":{"id":"f0eff93c3dd0f236","repo":"gitbutlerapp/gitbutler","slug":"visible-worktree-name-was-listed-more-than-once","errorCode":null,"errorMessage":"Visible worktree {name} was listed more than once","messagePattern":"Visible worktree (.+?) was listed more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/graph_rebase/creation.rs","lineNumber":354,"sourceCode":"                    format!(\n                        \"Visible detached worktree {} HEAD {} is missing from the editor\",\n                        tip.name, tip.id\n                    )\n                })?,\n            };\n            let name = tip.name.clone();\n            let checkout = Checkout::Worktree {\n                worktree_name: name.clone(),\n                selector: Selector {\n                    id: selector,\n                    revision: 0,\n                },\n                ref_name: tip.ref_name,\n                initial_head: tip.id,\n                merge_base_override: None,\n            };\n            if worktree_checkouts.insert(name.clone(), checkout).is_some() {\n                bail!(\"Visible worktree {name} was listed more than once\");\n            }\n        }\n\n        let checkouts = worktree_checkouts\n            .into_values()\n            .chain(head_selectors.into_iter().map(|selector| Checkout::Head {\n                selector,\n                merge_base_override: None,\n            }))\n            .collect();\n\n        Ok(Self {\n            graph,\n            initial_references: references,\n            checkouts,\n            repo: repo.clone().with_object_memory(),\n            history: RevisionHistory::new(),\n            workspace,","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/graph_rebase/creation.rs#L336-L372","documentation":"Visible worktrees are keyed by name in a map of checkouts; duplicates would make checkout identity ambiguous during materialization. If the worktree list yields the same name twice, creation of the rebase editor aborts rather than silently picking one.","triggerScenarios":"Calling `create_with_opts` when the underlying worktree enumeration returns two visible worktrees with identical names — typically a corrupted .git/worktrees metadata directory or two proxy entries sharing a name.","commonSituations":"Manually copied or hand-edited .git/worktrees directories; leftover worktree admin dirs after a crash; filesystem case-insensitivity causing name collisions; buggy external tooling duplicating worktree entries.","solutions":["Run `git worktree prune` to clean stale worktree metadata, then retry","Inspect .git/worktrees/ for duplicate admin directories and remove the invalid one","Ensure worktrees have unique names when creating them (`git worktree add <unique-path>`)"],"exampleFix":"// before: creating worktrees with colliding names\ngit worktree add ../repo feature && git worktree add ../repo2 feature\n// after: unique branch per worktree\ngit worktree add ../repo feature-a && git worktree add ../repo2 feature-b","handlingStrategy":"validation","validationCode":"let mut names = std::collections::HashSet::new();\nfor wt in visible_worktrees {\n    anyhow::ensure!(names.insert(wt.name.clone()), \"duplicate worktree name: {}\", wt.name);\n}","typeGuard":null,"tryCatchPattern":"match create_with_opts(&workspace, &tips, opts) {\n    Ok(ed) => ed,\n    Err(e) if e.to_string().contains(\"listed more than once\") => {\n        run_git(&repo, [\"worktree\", \"prune\"])?;\n        let ws = but_workspace::refresh(&repo)?;\n        create_with_opts(&ws, &tips, opts)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Run `git worktree prune` after crashes","Give every worktree a unique name/path","Do not hand-edit .git/worktrees metadata"],"tags":["git","worktree","duplicate"],"backgroundTag":"invalid-state-transition","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}