gitbutlerapp/gitbutler · error
Branch ' ' not found when checking for conflicts
Error message
Branch '{branch_name}' not found when checking for conflicts What it means
`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.
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>`
Defensive patterns
Strategy: validation
Validate before calling
if !branch_exists(branch_name) { eprintln!("branch {branch_name} missing"); return; } Try / catch
if let Err(e) = push_single_branch(ctx, name) {
if e.to_string().contains("not found when checking for conflicts") {
eprintln!("Branch '{name}' does not exist locally; run 'but branch list'");
}
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: Typo in branch name; branch was deleted or renamed before push; pushing a branch that was never created locally.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Branch ' ' not found
- Local branch ' ' not found
- Branch " " has no conflicted commits.
- Branch ' ' not found. Available branches
- Cannot apply non-existing branch
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/73e40885c37dbd3f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/push.rs:1234
let remote_names = repo.remote_names();
let target_branch =
but_core::extract_remote_name_and_short_name(target_ref_name.as_ref(), &remote_names)
.map(|(_, short_name)| short_name.to_string())
.unwrap_or_else(|| target_ref_name.shorten().to_string());
Ok(format!("refs/for/{target_branch}"))
}
/// Check if a push of this branch would include any conflicted commits.
/// The push covers the branch and everything beneath it, named by a branch
/// or not, so all of that is checked. Returns an error if conflicted commits
/// are found.
fn check_for_conflicted_commits(ctx: &Context, branch_name: &str) -> anyhow::Result<()> {
let branch = gix::refs::Category::LocalBranch.to_full_name(branch_name)?;
let Some(commits) =
crate::legacy::workspace::push_scope_with_expensive_commit_info(ctx, branch.as_ref())?
else {
anyhow::bail!("Branch '{branch_name}' not found when checking for conflicts");
};
let conflicted: Vec<gix::ObjectId> = commits
.iter()
.filter(|c| c.has_conflicts)
.map(|c| c.id)
.collect();
if conflicted.is_empty() {
return Ok(());
}
let repo = ctx.repo.get()?.clone().for_commit_shortening();
// Only pay for the map when the error actually prints.
let id_map = crate::IdMap::legacy_new_from_context(ctx).ok();
let conflicted_commits: Vec<String> = conflicted
.iter()
.map(|id| {
id_map
.as_ref()View on GitHub (pinned to 58e5313667)