{"record":{"id":"1cb7e77f06af8648","repo":"gitbutlerapp/gitbutler","slug":"expected-branch-identifier-got-please-use-a-b","errorCode":null,"errorMessage":"Expected branch identifier, got {}. Please use a branch name or branch CLI ID.","messagePattern":"Expected branch identifier, got (.+?)\\. 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":1140,"sourceCode":"                \"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}\n\nfn get_available_branch_names(ctx: &Context) -> anyhow::Result<Vec<String>> {\n    let lanes = crate::legacy::workspace::applied_lanes_with_expensive_commit_info(ctx)?;\n    let mut branch_names = Vec::new();\n\n    for stack in lanes {\n        for branch in &stack.branches {\n            branch_names.push(branch.name.clone());\n        }\n    }\n\n    branch_names.sort();\n    branch_names.dedup();","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1122-L1158","documentation":"The single matching CliId is neither a Branch nor a Worktree, so it cannot be converted to a branch name for pushing. The error reports the kind via kind_for_humans() and directs the user to a branch name or branch CLI ID.","triggerScenarios":"Passing a CliId that resolves to exactly one non-branch, non-worktree item (e.g. a commit) to `but push`; the match arm in resolve_branch_name falls through to the catch-all error.","commonSituations":"Using a commit's CLI ID with `but push`, mistaking a change/commit ID for a branch ID in stacked-workspace workflows.","solutions":["Use a branch name: `but push <branch-name>`.","List branches with `but branch list` and use a branch CLI ID.","If you intended to push a commit, move it onto a branch first, then push that branch."],"exampleFix":"// before\nbut push 3f\n// after\nbut push feature/login","handlingStrategy":"validation","validationCode":"const item = resolveCliId(id);\nif (item && item.kind !== 'branch' && item.kind !== 'worktree') {\n  throw new Error(`\"${id}\" is a ${item.kind}; 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 && /Expected branch identifier, got/.test(out.stderr)) {\n  const kind = out.stderr.match(/got ([\\w ]+)\\./)?.[1];\n  console.error(`\"${id}\" is a ${kind ?? 'non-branch item'}, not a branch.`);\n}","preventionTips":["Only pass branch or worktree identifiers to but push","Distinguish commit IDs from branch IDs before invoking","Default scripts to explicit branch names rather than generic CLI IDs"],"tags":["cli","branch","type-mismatch"],"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"}