{"record":{"id":"c6ee69404c147cdf","repo":"gitbutlerapp/gitbutler","slug":"identifier-branch-id-matches-multiple-non-bran","errorCode":null,"errorMessage":"Identifier '{branch_id}' matches multiple non-branch items. Please use a branch name or branch CLI ID.","messagePattern":"Identifier '(.+?)' matches multiple non-branch items\\. Please use a branch name or branch CLI ID\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1127,"sourceCode":"    }\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        }\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    }\n}","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1109-L1145","documentation":"The identifier matched multiple CliIds, but none of them are branch items (e.g. commits or other workspace entities). Since `but push` only accepts a branch, it asks for a branch name or a branch CLI ID.","triggerScenarios":"Passing an identifier to `but push` that matches several non-branch objects (e.g. multiple commits sharing a CliId prefix); cli_ids is non-empty but branch_names is empty in resolve_branch_name.","commonSituations":"Copy-pasting a commit CLI ID into `but push`, abbreviated IDs that resolve to commits in a stacked workspace, confusing commit IDs with branch IDs.","solutions":["Use a branch name instead of the matching identifier.","Get the branch's CLI ID from `but branch list` and use that.","If you meant to push a commit's changes, first assign/move it to a branch, then push that branch."],"exampleFix":"// before\nbut push c1\n// after\nbut push feature/login","handlingStrategy":"validation","validationCode":"if (!isBranchCliId(id) && !listBranches().some(b => b.name === id)) {\n  throw new Error(`\"${id}\" is not a branch; pass a branch name or branch CLI ID`);\n}\nbutPush(id);","typeGuard":null,"tryCatchPattern":"const out = await exec('but', ['push', id]);\nif (out.code !== 0 && /matches multiple non-branch items/.test(out.stderr)) {\n  console.error(`\"${id}\" is not a branch. Use: but branch list`);\n}","preventionTips":["Do not feed commit CLI IDs to but push","Resolve branch identifiers from but branch list, not from log output of commits","Validate the target is a branch before scripting the push"],"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"}