gitbutlerapp/gitbutler · error
Could not find stack containing commit {commit_ref}
Error message
Could not find stack containing commit {commit_ref} What it means
`but resolve <commit>` locates the commit by iterating applied stacks and traversing their commits for a matching oid; if no applied stack contains it, the search stays `None` and this error fires before edit mode is entered. Resolution only works for commits inside an applied workspace stack, because the fix happens through the stack's edit session.
Source
Thrown at crates/but/src/command/legacy/resolve.rs:239
let traversal = head
.tip
.attach(&repo)
.ancestors()
.sorting(Sorting::BreadthFirst)
.all()?;
for info in traversal {
let info = info?;
if info.id == commit_gix_oid {
found_stack_id = stack.id;
break 'outer;
}
}
}
}
let stack_id = found_stack_id
.ok_or_else(|| anyhow::anyhow!("Could not find stack containing commit {commit_ref}"))?;
drop(commit);
drop(repo);
// Enter edit mode
enter_edit_mode(ctx, commit_gix_oid, stack_id).context("Failed to enter edit mode")?;
// Show checkout message
if let Some(out) = out.for_human() {
writeln!(
out,
"{} {}",
t.important.paint("Checking out conflicted commit"),
commit_ref
)?;
}
// Now show the same status as `but resolve status` would showView on GitHub (pinned to caf1f223d3)
Solutions
- Confirm the commit sits in an applied stack: `but status` (apply the stack if not)
- If the commit already landed, there is nothing to resolve in the workspace
- Double-check the sha belongs to this repository and use the full oid
- Retry `but resolve <full-sha>` once the stack is applied
Example fix
# before but resolve 4a2f9c1 # error: Could not find stack containing commit 4a2f9c1 # after but status # locate the commit's stack; apply it if unapplied but resolve 4a2f9c1...
Defensive patterns
Strategy: validation
Validate before calling
# Verify the commit is reachable in an applied stack before resolving but status # the commit must belong to an applied stack, not a landed or plain-git branch but oplog # confirms the commit exists in this workspace's history
Try / catch
let out = Command::new("but").args(["resolve", sha]).output()?;
if !out.status.success()
&& String::from_utf8_lossy(&out.stderr).contains("Could not find stack containing commit")
{
// hint: apply the stack that owns the commit, or the commit already landed
} Prevention
- Only resolve commits that live in applied stacks — check `but status` first
- Use full oids copied from workspace output, not abbreviated foreign shas
- Apply or unarchive the owning stack before attempting resolution
When it happens
Trigger: Passing a commit that belongs to an unapplied or archived stack, to an already landed branch, or made outside the workspace directly on a Git branch; also a valid oid from a different repository.
Common situations: Stack unapplied to work on something else; commit already landed upstream; sha grabbed from `git log` of a real branch instead of workspace state.
Related errors
- Cannot push branch '{}': the push would include {} conflicte
- Stack has no branches
- When using OpenRouter, you must provide a valid API key
- HTTP Error ${response.statusText}: ${text}
- No stack selected!
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/f7808e87247a652c.
Report an issue: GitHub.