{"record":{"id":"960ff4ecf7baa003","repo":"gitbutlerapp/gitbutler","slug":"no-uncommitted-changes-to-discard","errorCode":null,"errorMessage":"No uncommitted changes to discard","messagePattern":"No uncommitted changes to discard","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but/src/command/legacy/discard.rs","lineNumber":526,"sourceCode":"                match selection {\n                    UncommittedSelection::All => builder.push_changes_from_uncommitted_area()?,\n                    UncommittedSelection::Changes(changes) => {\n                        for change in *changes {\n                            match change {\n                                UncommittedDiscardSource::HunkOrFile(change) => {\n                                    builder.push_changes_from_uncommitted(&change)?;\n                                }\n                                UncommittedDiscardSource::PathPrefix(hunks) => {\n                                    builder.push_changes_from_path_prefix(&hunks)?;\n                                }\n                            }\n                        }\n                    }\n                }\n                builder.reconcile_worktree_diff_specs()?;\n                builder.into_diff_specs()\n            };\n            anyhow::ensure!(!changes.is_empty(), \"No uncommitted changes to discard\");\n            let paths = paths_from_changes(&changes);\n            ExecutableDiscardOperation::Uncommitted { paths, changes }\n        }\n    };\n\n    let (mut outcome, mut ws) = but_transaction::with_transaction_with_perm(\n        ctx,\n        meta,\n        perm,\n        SnapshotDetails::new(oplog_operation_kind),\n        DryRun::No,\n        |mut tx| {\n            let outcome = match executable {\n                ExecutableDiscardOperation::Branches { branches, commits } => {\n                    if !commits.is_empty() {\n                        tx.discard_commits(commits.iter().map(|c| c.commit_id))?;\n                    }\n                    for branch in &branches {","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/discard.rs#L508-L544","documentation":"In the uncommitted branch of `but discard`, the worktree diff specs are reconciled and checked with `ensure!(!changes.is_empty())`. If there are no uncommitted changes matching the request, the CLI raises this error instead of starting a transaction that would do nothing.","triggerScenarios":"Running `but discard` on uncommitted changes when the worktree is clean; path filters that match no modified files; a prior operation (commit/absorb/discard) already consumed the changes between inspection and execution.","commonSituations":"Scripted discard after a previous command already committed or cleaned the worktree; discarding a path that is actually unmodified; stale terminal view where the user believes changes exist but they were committed via `but commit`.","solutions":["Run `but` to confirm there are uncommitted changes before discarding","Commit the changes (`but commit`) if you actually wanted to keep them — discard is destructive and skipped when there is nothing to remove","Check the path arguments; drop filters that exclude all modified files","Re-run after any concurrent `but` command that may have changed the worktree"],"exampleFix":"// before: clean worktree\nbut discard 3a  // Error: No uncommitted changes to discard\n\n// after: verify changes exist first\nbut               // shows uncommitted hunks\nbut discard 3a","handlingStrategy":"validation","validationCode":"# confirm uncommitted changes exist first\nbut status || but  # verify uncommitted hunks are listed\n[ -n \"$(git status --porcelain)\" ] || { echo \"nothing to discard\"; exit 0; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `but` before discard to confirm dirty worktree","Commit instead of discarding when changes should be kept","Beware path filters that exclude all modified files"],"tags":["cli","discard","worktree","no-op"],"backgroundTag":"empty-required-field","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"}