{"record":{"id":"495ed22a29f8ee2f","repo":"gitbutlerapp/gitbutler","slug":"ambiguous-branch-identifier-did-you-mean-one","errorCode":null,"errorMessage":"Ambiguous branch identifier '{}'. Did you mean one of:\n{}","messagePattern":"Ambiguous branch identifier '(.+?)'\\. Did you mean one of:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1121,"sourceCode":"                \"Branch '{}' not found. Available branches:\\n{}\",\n                branch_id,\n                format_branch_suggestions(&available_branches)\n            ));\n        }\n        return Ok(branch_id.to_string());\n    }\n\n    if cli_ids.len() > 1 {\n        let branch_names: Vec<String> = cli_ids\n            .iter()\n            .filter_map(|id| match id {\n                CliId::Branch(branch) => Some(branch.name.clone()),\n                _ => None,\n            })\n            .collect();\n\n        if !branch_names.is_empty() {\n            return Err(anyhow::anyhow!(\n                \"Ambiguous branch identifier '{}'. Did you mean one of:\\n{}\",\n                branch_id,\n                format_branch_suggestions(&branch_names)\n            ));\n        } else {\n            return Err(anyhow::anyhow!(\n                \"Identifier '{branch_id}' matches multiple non-branch items. Please use a branch name or branch CLI ID.\"\n            ));\n        }\n    }\n\n    match &cli_ids[0] {\n        CliId::Branch(branch) => Ok(branch.name.clone()),\n        CliId::Worktree { name, .. } => {\n            let repo = ctx.repo.get()?;\n            let branch = crate::utils::worktrees::worktree_branch(&repo, name.as_ref())?;\n            Ok(branch.shorten().to_string())\n        }","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1103-L1139","documentation":"Disambiguation failure in resolve_branch_name: the given branch identifier matched multiple branches (multiple CliId::Branch results). The error lists the candidate branch names so the user can supply a more specific identifier or the exact branch name.","triggerScenarios":"Passing a short/partial identifier (e.g. a CliId prefix like `ab`) to `but push` when two or more branches in the workspace share that prefix, resolved in resolve_branch_name via cli_ids with multiple CliId::Branch entries.","commonSituations":"Short stacks with many branches assigned nearby CLI IDs, using abbreviated IDs copied incompletely, workspaces where several branches start with the same prefix.","solutions":["Use the full branch name instead of the ambiguous short ID.","Copy the complete CLI ID from `but log` / `but branch list` rather than abbreviating.","Pick one of the branches listed in the error message.","Disambiguate by adding more characters of the CLI ID."],"exampleFix":"// before\nbut push ab\n// after\nbut push feature/login","handlingStrategy":"validation","validationCode":"const matches = listBranches().filter(b => b.cliId.startsWith(shortId));\nif (matches.length !== 1) throw new Error(`Ambiguous id \"${shortId}\"; use full name`);\nbutPush(matches[0].name);","typeGuard":null,"tryCatchPattern":"const out = await exec('but', ['push', id]);\nif (out.code !== 0 && /Ambiguous branch identifier/.test(out.stderr)) {\n  const candidates = out.stderr.split('one of:\\n')[1];\n  console.error(`Pick one explicitly:\\n${candidates}`);\n}","preventionTips":["Always use full branch names or full CLI IDs in scripts, never prefixes","When two branches share a prefix, disambiguate by name","Read candidate list from the error and retry with an exact name"],"tags":["cli","branch","ambiguity"],"backgroundTag":"invalid-identifier","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"}