gitbutlerapp/gitbutler · warning
No committed changes to discard
Error message
No committed changes to discard
What it means
`but discard` for committed changes collects the diff specs and paths for the selected commits; `NonEmpty::from_vec` for paths and `ensure!(!changes.is_empty())` guard the invariant that there is something to discard. If the computed change set is empty (or the path list is empty), the CLI raises this error rather than executing a no-op transaction.
Solutions
- Run `but` status / `but commit list` and confirm the targeted commit actually has file changes
- Drop the empty commit directly (e.g. `but commit drop`) instead of discarding its changes
- Remove or broaden path filters so at least one changed path is selected
- Re-check the workspace state; if a prior discard already applied, there is nothing left to do
Example fix
// before: empty commit targeted but discard <id-of-empty-commit> // Error: No committed changes to discard // after: pick a commit with real changes, verified via status output but but discard <id-with-changes>
Defensive patterns
Strategy: validation
Validate before calling
# ensure the chosen commit has file changes before discarding but commit list # confirm the target id shows changed files git show --stat <commit>
Prevention
- Inspect commit contents before discard
- Avoid discarding commits you already emptied
- Re-check state after prior discard/absorb operations
When it happens
Trigger: Selecting committed changes whose diff resolves to an empty change set — e.g. the commit is empty, the specified paths have no differences versus the source, or the requested discard range contains no actual file changes.
Common situations: Discarding an already-empty commit; path filters that exclude every change in the commit; re-running a discard that previously succeeded so nothing is left to discard; race where the target commit was rewritten/rebased meanwhile.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- No uncommitted changes to discard
- Aborting due to empty
- Could not discard all selected changes
- no commit IDs provided for discard
- no commit IDs provided for discard
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/857eb25cd15bfbeb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/discard.rs:496
.collect::<Vec<but_core::ui::TreeChange>>(),
);
}
builder.push_hunks_with_changes(
[hunk.hunk],
tree_changes
.as_ref()
.expect("tree changes are initialized for committed hunks"),
)
}
}
}
builder.into_diff_specs()
};
let paths: NonEmpty<BString> = NonEmpty::from_vec(paths.into_iter().collect())
.context("Paths must not be empty")?;
anyhow::ensure!(!changes.is_empty(), "No committed changes to discard");
ExecutableDiscardOperation::CommittedChanges {
source,
paths,
changes,
}
}
DiscardOperation::Uncommitted(selection) => {
let changes = {
let context_lines = ctx.settings.context_lines;
let (repo, ..) = ctx.workspace_and_db_mut_with_perm(perm.read_permission())?;
let mut builder = DiffSpecBuilder::new(&repo, context_lines);
match selection {
UncommittedSelection::All => builder.push_changes_from_uncommitted_area()?,
UncommittedSelection::Changes(changes) => {
for change in *changes {
match change {
UncommittedDiscardSource::HunkOrFile(change) => {
builder.push_changes_from_uncommitted(&change)?;View on GitHub (pinned to 58e5313667)