gitbutlerapp/gitbutler · error
No base branch configured
Error message
No base branch configured
What it means
branch_land first requires a managed GitButler workspace (gitbutler/workspace ref), then reads the configured base branch via legacy get_base_branch_data. When that returns None — a managed workspace exists but no target/base branch is configured in project metadata — the land aborts with this error before touching any refs.
Source
Thrown at crates/but-api/src/land/mod.rs:192
pub fn branch_land(
ctx: &mut Context,
branch: String,
no_ff: bool,
whole_stack: bool,
) -> anyhow::Result<BranchLandResult> {
let base_branch = {
let mut guard = ctx.exclusive_worktree_access();
{
let (_repo, ws, _db) = ctx.workspace_and_db_with_perm(guard.read_permission())?;
if !ws.kind.has_managed_ref() {
bail!(
"`but land` requires an active GitButler workspace (`gitbutler/workspace`). \
Switch into the workspace and try again."
);
}
}
crate::legacy::virtual_branches::get_base_branch_data(ctx, guard.write_permission())?
.ok_or_else(|| anyhow::anyhow!("No base branch configured"))?
};
let target_branch_name = base_branch.short_name.clone();
if target_branch_name.is_empty() {
bail!("Configured target branch has no branch name");
}
let fetch_remote_name = base_branch.remote_name.clone();
let push_remote_name = if base_branch.push_remote_name.is_empty() {
fetch_remote_name.clone()
} else {
base_branch.push_remote_name.clone()
};
if push_remote_name.is_empty() {
bail!("Configured target branch has no push remote");
}
// Triangular remotes (fetch remote != push remote) are out of scope for now: the post-land
// reconcile reads the fetch remote's tracking ref, so a push to a different remote would notView on GitHub (pinned to 2497b8007a)
Solutions
- Set the target (base) branch in the GitButler app for the project, then retry land.
- Programmatically call the set-base-branch flow (e.g. gitbutler_branch_actions::set_base_branch) with refs/remotes/<remote>/<branch> before landing.
- Verify with `but status` that a target branch is reported before invoking land.
Example fix
// before but_api::branch_land(ctx, branch, no_ff, whole_stack)?; // after let target: gitbutler_reference::RemoteRefname = "refs/remotes/origin/main".to_string().parse()?; gitbutler_branch_actions::set_base_branch(ctx, &target, perm)?; but_api::branch_land(ctx, branch, no_ff, whole_stack)?;
Defensive patterns
Strategy: validation
Validate before calling
// land preflight:
let has_base = crate::legacy::virtual_branches::get_base_branch_data(
ctx,
perm.read_permission(),
)?.is_some();
anyhow::ensure!(has_base, "configure a target branch before landing"); Prevention
- Complete onboarding (target selection) before exposing land actions.
- Include base-branch presence in preflight checks for any land flow.
- After restoring projects, verify target metadata before operations.
When it happens
Trigger: branch_land on a project whose workspace ref exists but whose base-branch data is absent: onboarding interrupted before target selection, metadata cleared or lost, or partially migrated/restored projects.
Common situations: Workspace created but the 'set target branch' step skipped; project restored from backup without metadata; users deliberately clearing the target then running land.
Related errors
- Target branch {target_ref_name} not found
- No push remote set or more than one remote
- No HEAD reference found for remote {remote_name}
- Remote HEAD for {remote_name} is not symbolic
- Branch {branch_name} not found
AI-assisted analysis of gitbutlerapp/gitbutler@2497b8007a (2026-08-17).
Data as JSON: /api/errors/7abe634facb0fe81.
Report an issue: GitHub.