{"record":{"id":"d9b4c4d5d8da5b59","repo":"gitbutlerapp/gitbutler","slug":"target-branch-target-ref-name-not-found","errorCode":null,"errorMessage":"Target branch {target_ref_name} not found","messagePattern":"Target branch (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/land/merge.rs","lineNumber":46,"sourceCode":"/// rename-aware merge commit. Conflicts bail here, before anything is pushed or moved.\npub(super) fn decide_land_outcome(\n    repo: &gix::Repository,\n    branch_name: &str,\n    fetch_remote_name: &str,\n    target_branch_name: &str,\n    no_ff: bool,\n) -> anyhow::Result<LandOutcome> {\n    let feature_ref_name = format!(\"refs/heads/{branch_name}\");\n    let feature_oid = repo\n        .try_find_reference(&feature_ref_name)?\n        .ok_or_else(|| anyhow::anyhow!(\"Branch {branch_name} not found\"))?\n        .into_fully_peeled_id()?\n        .detach();\n\n    let target_ref_name = format!(\"refs/remotes/{fetch_remote_name}/{target_branch_name}\");\n    let target_oid = repo\n        .try_find_reference(&target_ref_name)?\n        .ok_or_else(|| anyhow::anyhow!(\"Target branch {target_ref_name} not found\"))?\n        .into_fully_peeled_id()?\n        .detach();\n\n    // No common ancestor: refuse rather than merge two unrelated histories onto the target.\n    let Some(merge_base) = super::merge_base_opt(repo, feature_oid, target_oid)? else {\n        bail!(\n            \"Cannot land {branch_name}: it shares no history with {fetch_remote_name}/{target_branch_name}\"\n        );\n    };\n\n    if merge_base == feature_oid {\n        return Ok(LandOutcome::AlreadyIntegrated);\n    }\n    if merge_base == target_oid && !no_ff {\n        return Ok(LandOutcome::FastForward {\n            feature_oid,\n            target_oid,\n        });","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/land/merge.rs#L28-L64","documentation":"During land, after fetch_target_remote, the target is resolved as refs/remotes/<fetch_remote>/<target_branch> in decide_land_outcome. If that remote-tracking ref is absent — the target branch does not exist under the fetch remote, the remote name is wrong, or the fetch produced no such ref — the land aborts before any push.","triggerScenarios":"branch_land where the configured target branch has no refs/remotes/<remote>/<target> ref: upstream branch deleted or renamed (main vs master), base-branch data pointing at an old remote name, or a fetch that created no tracking ref for that branch.","commonSituations":"Upstream default branch renamed while the workspace still targets the old name; remote pruned; target configured against a fork remote that lacks the branch; offline fetch that silently skipped ref updates.","solutions":["Confirm the tracking ref: git fetch <remote> && git branch -r --list '<remote>/<target>'.","Update the workspace target branch to a branch that exists on the remote (GitButler target/base-branch settings).","If the upstream branch was renamed, retarget the workspace to the new name before re-running land."],"exampleFix":"git fetch origin\ngit branch -r --list 'origin/*'   # confirm the target exists upstream\n# retarget the workspace to the real default branch, then:\nbut land feat/auth","handlingStrategy":"validation","validationCode":"fn target_tracking_ref_exists(\n    repo: &gix::Repository,\n    fetch_remote: &str,\n    target_branch: &str,\n) -> anyhow::Result<bool> {\n    Ok(repo\n        .try_find_reference(&format!(\"refs/remotes/{fetch_remote}/{target_branch}\"))?\n        .is_some())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch the target remote and verify its tracking ref before invoking land.","Re-align the workspace target after upstream default-branch renames.","Fail fast in preflight when the configured target has no remote ref."],"tags":["land","target-branch","remote-tracking-ref","git-refs"],"backgroundTag":"remote-tracking-branch-missing","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}