{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1129,"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        _ => Err(anyhow::anyhow!(\n            \"Expected branch identifier, got {}. Please use a branch name or branch CLI ID.\",\n            cli_ids[0].kind_for_humans()\n        )),\n    }","sourceCodeStart":1111,"sourceCodeEnd":1147,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/push.rs#L1111-L1147","documentation":"When the argument parses to more than one CLI id in the IdMap and at least one is a branch, `resolve_branch_name` refuses to guess and lists the matching branch names via `format_branch_suggestions`. Abbreviated numeric ids or shared name prefixes are the usual cause.","triggerScenarios":"Passing an abbreviated CLI id (e.g. `but push 12`) that matches several branches, or a name/prefix that resolves to multiple workspace branches.","commonSituations":"Long-lived workspaces accumulate similarly named branches (feature-x, feature-x-2); short ids from `but status` reused after new branches shifted the numbering.","solutions":["Use the full, unique branch name shown in the 'Did you mean one of' list","Lengthen an abbreviated id until it matches exactly one item","Re-check current ids with `but status` before scripting them"],"exampleFix":"# before\nbut push 12\n# error: Ambiguous branch identifier '12'. Did you mean one of: ...\n\n# after\nbut push feature-x   # full unique name from the suggestion list","handlingStrategy":"validation","validationCode":"# Before scripting a short id, ensure it resolves to exactly one branch\nbut status | grep -c \"$id\"   # more than one hit -> use the full unique name instead","typeGuard":null,"tryCatchPattern":"// Extract the 'Did you mean one of:' candidates from the failure\nlet err = String::from_utf8_lossy(&out.stderr).to_string();\nif err.contains(\"Ambiguous branch identifier\") {\n    let candidates: Vec<&str> = err.lines().skip_while(|l| !l.contains(\"Did you mean\")).skip(1).collect();\n    // let the user disambiguate, then retry with the full name\n}","preventionTips":["Prefer full branch names over abbreviated ids in scripts","Capture ids from a fresh `but status` right before use, never cache them","Rename near-duplicate branches (feature-x vs feature-x-2) to avoid future collisions"],"tags":["push","branch-resolution","ambiguous-id","cli-id"],"backgroundTag":"ambiguous-identifier","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}