{"record":{"id":"ac76a83368e46992","repo":"gitbutlerapp/gitbutler","slug":"gitbutler-mode-exit-required-please-run-but-tear","errorCode":null,"errorMessage":"GitButler mode exit required: please run `but teardown` to preserve your work.","messagePattern":"GitButler mode exit required: please run `but teardown` to preserve your work\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/setup.rs","lineNumber":555,"sourceCode":"            writeln!(writer)?;\n            writeln!(\n                writer,\n                \"{}\",\n                theme::get()\n                    .attention\n                    .paint(\"⚠ Detected commits on top of gitbutler/workspace\")\n            )?;\n            writeln!(writer)?;\n            writeln!(\n                writer,\n                \"{}\",\n                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`.\")\n            )?;\n            writeln!(writer)?;\n        }\n\n        // After teardown, we should not continue with the original command\n        anyhow::bail!(\n            \"GitButler mode exit required: please run `but teardown` to preserve your work.\"\n        );\n    }\n\n    Ok(())\n}\n","sourceCodeStart":537,"sourceCodeEnd":562,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/setup.rs#L537-L562","documentation":"check_workspace_commits_before_init detects commits made directly on top of the gitbutler/workspace branch. Such commits sit outside GitButler's virtual-branch model and operating on that state could lose work, so after printing a warning every command aborts until `but teardown` exits GitButler mode cleanly while preserving the work.","triggerScenarios":"Committing manually while gitbutler/workspace is checked out (e.g. plain `git commit` on that branch), then running any but command with workspace checks enabled (WorkspaceCheck::Enabled).","commonSituations":"Users switching branches with plain git inside a GitButler-managed repo, IDEs auto-committing on the checked-out workspace branch, following generic git tutorials inside a GitButler project.","solutions":["Run `but teardown` - it preserves the work and exits GitButler mode","After teardown, re-run `but setup` if you want to re-enter GitButler mode","Prevent recurrence: commit through GitButler's own flow, never directly on gitbutler/workspace"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/bin/sh\nbranch=$(git symbolic-ref --short HEAD 2>/dev/null || true)\nif [ \"$branch\" = \"gitbutler/workspace\" ]; then\n  echo \"run `but teardown` before continuing\" >&2; exit 1\nfi\n# safe to run but commands","typeGuard":null,"tryCatchPattern":"let out = cmd.output()?;\nif !out.status.success() && String::from_utf8_lossy(&out.stderr).contains(\"but teardown\") {\n    // safety stop: surface to the user, never force past it\n}","preventionTips":["Never commit directly while gitbutler/workspace is checked out","Wrap scripted but usage with a checked-branch guard","Treat this abort as a safety stop - run but teardown, do not work around it"],"tags":["git","workspace","teardown","safety","branch"],"backgroundTag":"workspace-branch-commits-detected","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}