gitbutlerapp/gitbutler · error
Not currently on a gitbutler/* branch.
Error message
Not currently on a gitbutler/* branch.
What it means
`check_project_setup` in the legacy `but` CLI setup path verifies the repository HEAD points at a `gitbutler/*` branch before initializing a context. If HEAD's short name does not start with `gitbutler/`, the setup aborts because the legacy workspace machinery only operates in GitButler-managed states. This is a precondition check, not a Git failure.
Solutions
- Switch the repository back to the GitButler workspace branch (`git switch gitbutler/workspace`, or `gitbutler/edit` when editing) or re-enter GitButler mode for the project (`but` app or the setup command that creates the workspace).
- Verify HEAD: `git symbolic-ref --short HEAD` must start with `gitbutler/`.
- If the project should no longer use GitButler, do not call this legacy setup path; use non-legacy workflows.
Example fix
// before (plain git checkout) $ but status Error: Not currently on a gitbutler/* branch. // after $ git switch gitbutler/workspace $ but status
Defensive patterns
Strategy: validation
Validate before calling
let head_name = std::fs::read_to_string(".git/HEAD").ok()
.map(|h| h.trim().trim_start_matches("ref: ").to_string())
.unwrap_or_default();
if !head_name.starts_with("gitbutler/") {
eprintln!("not in gitbutler mode (HEAD={head_name}); re-enter the workspace first");
std::process::exit(1);
} Type guard
fn is_gitbutler_head(head_name: &str) -> bool {
head_name.starts_with("gitbutler/")
} Try / catch
match result {
Err(e) if e.to_string().contains("Not currently on a gitbutler/* branch") => {
// prompt user to re-enter the GitButler workspace
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Check `git symbolic-ref --short HEAD` before invoking `but` legacy commands
- Do not plain-`git switch` away from `gitbutler/*` while using the CLI
- Automate re-entering the workspace in CI before running `but`
When it happens
Trigger: Calling `init_ctx`/`check_project_setup` while HEAD is on a normal branch (e.g. `main`), a detached HEAD with a non-gitbutler referent, or any state where the user has left the GitButler workspace (e.g. via `but legacy abandon` or plain `git switch main`).
Common situations: Running `but` legacy commands after switching branches with plain git; a teammate cloned a repo without the virtual-branches state; GitButler was exited/paused for the project; automation invoking `but` in a plain git checkout.
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
- Aborting due to empty branch name
- Bare repositories are not supported.
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch " " has no conflicted commits.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/ffc8a25bfb110ba4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/setup.rs:553
/// If so, returns true
/// Otherwise, returns an error with a message indicating what is not setup.
/// It will check:
/// - if the repository exists
/// - if the project is registered in GitButler
/// - if there is a remote
/// - if there is a default target branch set
/// - if we're on a gitbutler/* branch
pub fn check_project_setup(ctx: &Context, perm: &RepoShared) -> anyhow::Result<bool> {
let (repo, ws, _) = ctx.workspace_and_db_with_perm(perm)?;
// check if we're on a gitbutler/* branch
let head = repo.head()?;
let head_name = head
.referent_name()
.map(|n| n.shorten().to_owned())
.unwrap_or_default();
if !head_name.starts_with(b"gitbutler/") {
anyhow::bail!("Not currently on a gitbutler/* branch.");
}
// When on gitbutler/edit, the project was already set up when entering edit mode.
// The workspace graph built from gitbutler/edit doesn't expose the target ref or
// remote configuration, but both are still configured in virtual_branches.toml
// and will be accessible when returning to gitbutler/workspace.
if head_name == b"gitbutler/edit" {
return Ok(true);
}
// TODO(legacy): it's fine to have no target.
if ws.graph.project_meta.target_ref.is_none() {
anyhow::bail!("No default target branch set.");
}
// check if there is a remote
if ws.push_remote_name().is_none()
&& repoView on GitHub (pinned to 58e5313667)