{"record":{"id":"7abe634facb0fe81","repo":"gitbutlerapp/gitbutler","slug":"no-base-branch-configured","errorCode":null,"errorMessage":"No base branch configured","messagePattern":"No base branch configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/land/mod.rs","lineNumber":192,"sourceCode":"pub fn branch_land(\n    ctx: &mut Context,\n    branch: String,\n    no_ff: bool,\n    whole_stack: bool,\n) -> anyhow::Result<BranchLandResult> {\n    let base_branch = {\n        let mut guard = ctx.exclusive_worktree_access();\n        {\n            let (_repo, ws, _db) = ctx.workspace_and_db_with_perm(guard.read_permission())?;\n            if !ws.kind.has_managed_ref() {\n                bail!(\n                    \"`but merge` requires an active GitButler workspace (`gitbutler/workspace`). \\\n                     Switch into the workspace and try again.\"\n                );\n            }\n        }\n        crate::legacy::virtual_branches::get_base_branch_data(ctx, guard.write_permission())?\n            .ok_or_else(|| anyhow::anyhow!(\"No base branch configured\"))?\n    };\n\n    let target_branch_name = base_branch.short_name.clone();\n    if target_branch_name.is_empty() {\n        bail!(\"Configured target branch has no branch name\");\n    }\n    let fetch_remote_name = base_branch.remote_name.clone();\n    let push_remote_name = if base_branch.push_remote_name.is_empty() {\n        fetch_remote_name.clone()\n    } else {\n        base_branch.push_remote_name.clone()\n    };\n    if push_remote_name.is_empty() {\n        bail!(\"Configured target branch has no push remote\");\n    }\n\n    // Triangular remotes (fetch remote != push remote) are out of scope for now: the post-land\n    // reconcile reads the fetch remote's tracking ref, so a push to a different remote would not","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/land/mod.rs#L174-L210","documentation":"The public `branch_land` (merge) entrypoint needs a configured base (target) branch for the GitButler workspace. `get_base_branch_data` returns `None` when the workspace has no base branch configured, and this error is raised. Outside a `gitbutler/workspace` the code path differs (that case is handled earlier with its own error), so this error specifically means: inside a workspace, but no base branch data exists.","triggerScenarios":"Calling `but merge` / `branch_land` in a GitButler workspace whose base/target branch was never set (e.g. workspace created without choosing a target); base branch data was cleared from workspace metadata.","commonSituations":"Newly initialized workspace where the user never picked a target branch; workspace metadata corrupted or partially migrated; working with `but merge` before running the normal branch/apply flow that establishes the base.","solutions":["Set the workspace's base/target branch (via the GitButler UI or `but` workspace target configuration, e.g. `but branch new --set-target` / project target setup).","Verify `git config gitbutler.*` / workspace metadata contains a base branch, or re-initialize the workspace.","Confirm you are inside a proper GitButler workspace (`gitbutler/workspace` branch exists) so the right code path runs.","Fetch the remote first, then re-set the target so `refs/remotes/<remote>/<target>` resolves."],"exampleFix":"// before\nbut merge; // fails: no base branch configured\n// after\nbut workspace target --set origin/main; // configure base branch first\nbut merge;","handlingStrategy":"validation","validationCode":"// confirm a base branch is configured before calling merge\nlet base = get_base_branch_data(ctx, perm)?;\nif base.is_none() {\n    eprintln!(\"no base branch configured; set workspace target first\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match branch_land(ctx, ...) {\n    Err(e) if e.to_string().contains(\"No base branch configured\") => {\n        prompt_user_to_set_target_branch()?;\n    }\n    other => other?,\n}","preventionTips":["Set the workspace target/base branch right after workspace creation","Check `but` workspace target configuration in setup scripts before merging","Re-set the target after fetching if remote branches changed"],"tags":["git","configuration","workspace","merge"],"backgroundTag":"missing-config-value","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"}