{"record":{"id":"07cf01d7666b8412","repo":"gitbutlerapp/gitbutler","slug":"cannot-uncommit-commits-that-would-result-in-merge","errorCode":null,"errorMessage":"Cannot uncommit commits that would result in merge conflicts","messagePattern":"Cannot uncommit commits that would result in merge conflicts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/squash.rs","lineNumber":1552,"sourceCode":"                    MoveCommittedFilesOperation { target, .. },\n                ) => SquashOutcome::Hunks { target, new_commit },\n            };\n            Ok((outcome, Some(ws)))\n        }\n        ExecutableSquashOperation::Uncommit(op) => {\n            if op.has_commit_sources() {\n                let but_api::commit::types::UncommitResult {\n                    workspace,\n                    uncommitted_ids: _,\n                } = but_api::commit::uncommit::commit_uncommit_only_with_perm(\n                    ctx,\n                    op.commit_sources().collect(),\n                    None,\n                    DryRun::Yes,\n                    perm,\n                )?;\n\n                anyhow::ensure!(\n                    !workspace.is_conflicted(),\n                    \"Cannot uncommit commits that would result in merge conflicts\"\n                );\n            }\n\n            let snapshot_details = SnapshotDetails::new(OperationKind::UndoCommit);\n            let ws = but_transaction::with_transaction_with_perm(\n                ctx,\n                meta,\n                perm,\n                snapshot_details,\n                DryRun::No,\n                |mut tx| {\n                    match &op {\n                        UncommitOperation::Commits { sources } => {\n                            if !sources.is_empty() {\n                                tx.uncommit_commits(sources.iter().map(|c| c.commit_id))?;\n                            }","sourceCodeStart":1534,"sourceCodeEnd":1570,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/squash.rs#L1534-L1570","documentation":"Before actually uncommitting (undoing) a commit, the code performs the operation in `DryRun::Yes` mode and checks the resulting workspace for conflicts. This error aborts the uncommit when the dry run shows the workspace would end up conflicted, protecting the user from a half-applied undo.","triggerScenarios":"Running `but uncommit <commit>` where moving the commit's changes back into the workspace overlaps with divergent local changes: the commit's files are heavily modified in the workspace, other stacks touch the same paths, or the workspace state has diverged from the commit graph.","commonSituations":"Undoing a commit after manually editing the same files in the working tree, uncommitting an old commit from a stack that later commits also modified, or resolving one conflict by hand before another operation already left markers.","solutions":["commit or stash your working-tree changes, then retry `but uncommit`","uncommit the most recent commit of the stack instead of an older one, so fewer overlapping moves occur","resolve existing conflicts in the workspace first (check `but status` for conflicted state) before uncommitting"],"exampleFix":"// before\nbut uncommit 3abc   # workspace has edits to the same files\n// after\ngit stash && but uncommit 3abc && git stash pop","handlingStrategy":"try-catch","validationCode":"// check workspace health before uncommitting\nif but_status_reports_conflicted() { eprintln!(\"Resolve conflicts first\"); }","typeGuard":null,"tryCatchPattern":"match uncommit(ctx, id) {\n    Err(e) if e.to_string().contains(\"merge conflicts\") => {\n        eprintln!(\"Commit/stash working-tree changes, then retry uncommit.\");\n    }\n    other => other?,\n}","preventionTips":["keep the working tree clean before stack surgery","uncommit the tip of a stack rather than deep commits","run `but status` and clear conflicts before undo operations"],"tags":["git","conflict","workspace"],"backgroundTag":"invalid-state-transition","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"}