{"record":{"id":"f7808e87247a652c","repo":"gitbutlerapp/gitbutler","slug":"could-not-find-stack-containing-commit-commit-ref","errorCode":null,"errorMessage":"Could not find stack containing commit {commit_ref}","messagePattern":"Could not find stack containing commit (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":239,"sourceCode":"            let traversal = head\n                .tip\n                .attach(&repo)\n                .ancestors()\n                .sorting(Sorting::BreadthFirst)\n                .all()?;\n\n            for info in traversal {\n                let info = info?;\n                if info.id == commit_gix_oid {\n                    found_stack_id = stack.id;\n                    break 'outer;\n                }\n            }\n        }\n    }\n\n    let stack_id = found_stack_id\n        .ok_or_else(|| anyhow::anyhow!(\"Could not find stack containing commit {commit_ref}\"))?;\n\n    drop(commit);\n    drop(repo);\n\n    // Enter edit mode\n    enter_edit_mode(ctx, commit_gix_oid, stack_id).context(\"Failed to enter edit mode\")?;\n\n    // Show checkout message\n    if let Some(out) = out.for_human() {\n        writeln!(\n            out,\n            \"{} {}\",\n            t.important.paint(\"Checking out conflicted commit\"),\n            commit_ref\n        )?;\n    }\n\n    // Now show the same status as `but resolve status` would show","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/resolve.rs#L221-L257","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Stack unapplied to work on something else; commit already landed upstream; sha grabbed from `git log` of a real branch instead of workspace state.","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"],"exampleFix":"# before\nbut resolve 4a2f9c1\n# error: Could not find stack containing commit 4a2f9c1\n\n# after\nbut status                   # locate the commit's stack; apply it if unapplied\nbut resolve 4a2f9c1...","handlingStrategy":"validation","validationCode":"# Verify the commit is reachable in an applied stack before resolving\nbut status   # the commit must belong to an applied stack, not a landed or plain-git branch\nbut oplog    # confirms the commit exists in this workspace's history","typeGuard":null,"tryCatchPattern":"let out = Command::new(\"but\").args([\"resolve\", sha]).output()?;\nif !out.status.success()\n    && String::from_utf8_lossy(&out.stderr).contains(\"Could not find stack containing commit\")\n{\n    // hint: apply the stack that owns the commit, or the commit already landed\n}","preventionTips":["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"],"tags":["resolve","workspace","commit-lookup","stack"],"backgroundTag":"commit-not-in-stack","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}