{"record":{"id":"73e40885c37dbd3f","repo":"gitbutlerapp/gitbutler","slug":"branch-branch-name-not-found-when-checking-for-conflicts","errorCode":null,"errorMessage":"Branch '{branch_name}' not found when checking for conflicts","messagePattern":"Branch '(.+?)' not found when checking for conflicts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1234,"sourceCode":"    let remote_names = repo.remote_names();\n    let target_branch =\n        but_core::extract_remote_name_and_short_name(target_ref_name.as_ref(), &remote_names)\n            .map(|(_, short_name)| short_name.to_string())\n            .unwrap_or_else(|| target_ref_name.shorten().to_string());\n\n    Ok(format!(\"refs/for/{target_branch}\"))\n}\n\n/// Check if a push of this branch would include any conflicted commits.\n/// The push covers the branch and everything beneath it, named by a branch\n/// or not, so all of that is checked. Returns an error if conflicted commits\n/// are found.\nfn check_for_conflicted_commits(ctx: &Context, branch_name: &str) -> anyhow::Result<()> {\n    let branch = gix::refs::Category::LocalBranch.to_full_name(branch_name)?;\n    let Some(commits) =\n        crate::legacy::workspace::push_scope_with_expensive_commit_info(ctx, branch.as_ref())?\n    else {\n        anyhow::bail!(\"Branch '{branch_name}' not found when checking for conflicts\");\n    };\n\n    let conflicted: Vec<gix::ObjectId> = commits\n        .iter()\n        .filter(|c| c.has_conflicts)\n        .map(|c| c.id)\n        .collect();\n    if conflicted.is_empty() {\n        return Ok(());\n    }\n    let repo = ctx.repo.get()?.clone().for_commit_shortening();\n    // Only pay for the map when the error actually prints.\n    let id_map = crate::IdMap::legacy_new_from_context(ctx).ok();\n    let conflicted_commits: Vec<String> = conflicted\n        .iter()\n        .map(|id| {\n            id_map\n                .as_ref()","sourceCodeStart":1216,"sourceCodeEnd":1252,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1216-L1252","documentation":"`check_for_conflicted_commits` builds the full local-branch ref name and asks for push scope with expensive commit info; if the workspace returns None the branch does not exist (or has no push scope), so it bails.","triggerScenarios":"`push_single_branch_impl` calls this for a branch name that is not a valid existing local branch, or push_scope_with_expensive_commit_info finds no workspace scope for it.","commonSituations":"Typo in branch name; branch was deleted or renamed before push; pushing a branch that was never created locally.","solutions":["Run `but branch list` (or `git branch`) to confirm the branch exists","Correct the branch name passed to `but push`","Create the branch if it was never created: `but branch create <name>`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if !branch_exists(branch_name) { eprintln!(\"branch {branch_name} missing\"); return; }","typeGuard":null,"tryCatchPattern":"if let Err(e) = push_single_branch(ctx, name) {\n    if e.to_string().contains(\"not found when checking for conflicts\") {\n        eprintln!(\"Branch '{name}' does not exist locally; run 'but branch list'\");\n    }\n}","preventionTips":["Verify the branch exists with `but branch list` before pushing","Avoid renaming/deleting branches between status and push","Script against branch names captured from `but status`, not memory"],"tags":["git","branch","not-found","cli"],"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"}