{"record":{"id":"75d0adb1a26c69f1","repo":"gitbutlerapp/gitbutler","slug":"branch-not-found-available-branches","errorCode":null,"errorMessage":"Branch '{}' not found. Available branches:\n{}","messagePattern":"Branch '(.+?)' not found\\. Available branches:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1102,"sourceCode":"        flags.push(but_gerrit::PushFlag::Private);\n    }\n\n    Ok(flags)\n}\n\nfn resolve_branch_name(\n    ctx: &mut Context,\n    id_map: &IdMap,\n    branch_id: &str,\n) -> anyhow::Result<String> {\n    // Try to resolve as CliId first\n    let cli_ids = id_map.parse_using_context(branch_id, ctx)?;\n\n    if cli_ids.is_empty() {\n        // If no CliId matches, treat as literal branch name but validate it exists\n        let available_branches = get_available_branch_names(ctx)?;\n        if !available_branches.contains(&branch_id.to_string()) {\n            return Err(anyhow::anyhow!(\n                \"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() {","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1084-L1120","documentation":"`but push <branch>` could not resolve the given identifier: it matched no CliId and is not a literal branch name in the workspace. The error lists the available branch names (via format_branch_suggestions) so the user can pick a valid one.","triggerScenarios":"Calling `but push <branch_id>` (or handle/handle_dry_run -> resolve_branch_name) with a typo'd branch name, a branch that was deleted/merged, or an identifier string that matches nothing in the id_map.","commonSituations":"Typing a branch name from memory, referencing a branch deleted after a stack rebase, running scripts against a stale branch list, case-sensitivity mismatches in branch names.","solutions":["Run `but branch list` (or read the suggestions in the error) and use an exact existing branch name.","Check for typos and case in the branch name.","Use the branch's CLI ID shown by `but log`/`but branch list` instead of the name.","Recreate or restore the branch if it was deleted (e.g. `git branch <name> <sha>`)."],"exampleFix":"// before\nbut push featue/login\n// after\nbut push feature/login","handlingStrategy":"validation","validationCode":"but branch list | grep -qx \"$BRANCH\" || { echo \"branch '$BRANCH' not found\"; exit 1; }\nbut push \"$BRANCH\"","typeGuard":null,"tryCatchPattern":"const out = await exec('but', ['push', branch]);\nif (out.code !== 0 && /not found\\. Available branches:/.test(out.stderr)) {\n  const suggestions = out.stderr.split('Available branches:\\n')[1];\n  console.error(`Branch \"${branch}\" does not exist. Options:\\n${suggestions}`);\n}","preventionTips":["List branches (but branch list) before scripting a push","Reference branches by full name or copied CLI ID, not from memory","Re-check branch existence after rebases or cleanups that may delete branches"],"tags":["cli","branch","not-found"],"backgroundTag":"entity-not-found","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"}