gitbutlerapp/gitbutler · error
GitButler mode exit required: please run `but teardown` to…
Error message
GitButler mode exit required: please run `but teardown` to preserve your work.
What it means
check_workspace_commits_before_init detects that the user has committed real commits directly on the gitbutler/workspace branch, which GitButler requires to be free of direct commits. The CLI offers an interactive teardown flow; after handling (or when teardown is the required path) it always bails with this message so the original command does not continue until GitButler mode is exited via `but teardown`.
Solutions
- Run `but teardown` as instructed to preserve your work and exit GitButler mode, then re-run the original command.
- Inspect `git log gitbutler/workspace` to confirm the direct commits before/after teardown.
- Avoid committing directly on gitbutler/workspace; commit through `but commit` instead.
Example fix
// before but push # fails: direct commits on workspace // after but teardown # preserves work, exits GitButler mode but setup && but push
Defensive patterns
Strategy: validation
Validate before calling
# fail early if the workspace branch has direct commits git rev-parse --verify gitbutler/workspace >/dev/null 2>&1 \ && [ -n "$(git log gitbutler/workspace --not --remotes=origin --oneline 2>/dev/null)" ] \ && echo "Run 'but teardown' first"
Prevention
- Never `git commit` while on gitbutler/workspace; use `but commit`
- Run `but teardown` as soon as direct workspace commits are noticed
- Audit the workspace branch log after manual git operations
When it happens
Trigger: Running any but command (with WorkspaceCheck::Enabled) on a repository where the gitbutler/workspace branch has non-workspace commits directly on it.
Common situations: Users who committed with plain `git commit` while on gitbutler/workspace; repos migrated from manual GitButler usage; recovering from interrupted GitButler operations.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- You are in conflict resolution mode. Finish with `but…
- Aborting due to empty branch name
- Bare repositories are not supported.
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/ac76a83368e46992.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/setup.rs:555
writeln!(writer)?;
writeln!(
writer,
"{}",
theme::get()
.attention
.paint("⚠ Detected commits on top of gitbutler/workspace")
)?;
writeln!(writer)?;
writeln!(
writer,
"{}",
theme::get().hint.paint("GitButler detected that you have committed directly on the\ngitbutler/workspace branch. To preserve your work and\nfix up things, please run `but teardown`.")
)?;
writeln!(writer)?;
}
// After teardown, we should not continue with the original command
anyhow::bail!(
"GitButler mode exit required: please run `but teardown` to preserve your work."
);
}
Ok(())
}
View on GitHub (pinned to 58e5313667)