{"record":{"id":"567a4ee8b1a1a89e","repo":"gitbutlerapp/gitbutler","slug":"branch-ref-name-has-no-tracking-branch","errorCode":null,"errorMessage":"Branch '{ref_name}' has no tracking branch","messagePattern":"Branch '(.+?)' has no tracking branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-core/src/branch/mod.rs","lineNumber":63,"sourceCode":"                .map(|reference| {\n                    reference.map(|_| {\n                        full_name\n                            .try_into()\n                            .expect(\"constructed remote-tracking refname must be valid\")\n                    })\n                })\n        })\n        .collect::<Result<Vec<gix::refs::FullName>, _>>()?;\n\n    if remote_matches.len() == 1 {\n        return Ok(Cow::Owned(\n            remote_matches\n                .pop()\n                .expect(\"exactly one remote match exists\"),\n        ));\n    }\n\n    bail!(\"Branch '{ref_name}' has no tracking branch\")\n}\n\n/// A way to safely delete branches, which is only the case it's checked out nowhere.\npub mod safe_delete;\n\n/// State for reuse when [safely deleting references](SafeDelete::delete_reference).\n#[derive(Debug)]\npub struct SafeDelete {\n    /// A mapping of one or more worktree paths that are affected by changes to the keyed reference name.\n    worktrees_by_ref: WorktreePathByRef,\n}\n","sourceCodeStart":45,"sourceCodeEnd":75,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-core/src/branch/mod.rs#L45-L75","documentation":"resolve_tracking_branch_ref_name() inspects the branch's remote-tracking configuration and bails when the local branch has no upstream/tracking branch configured, so no remote tracking ref name can be derived. Callers use the result for push/pull and integration-graph computations, which all require a remote counterpart.","triggerScenarios":"Calling remote_for_reference, get_initial_integration_steps_for_branch, or related integration functions with a purely local branch (never pushed) or a branch whose branch.<name>.remote config entry was removed.","commonSituations":"Creating a new local branch and immediately requesting integration status; cloning config stripped the upstream; a user deleted the remote but kept local branches; branches created from another local branch without -u.","solutions":["Set a tracking branch: git branch --set-upstream-to=<remote>/<branch> <ref_name>","Push the branch once with -u/--set-upstream so tracking is established","Check .git/config for a [branch \"<name>\"] remote section before calling the API","Skip remote integration steps for branches known to have no upstream"],"exampleFix":"// before\nlet remote = repo.resolve_tracking_branch_ref_name(ref_name)?;\n// after\nif let Ok(remote) = repo.resolve_tracking_branch_ref_name(ref_name) {\n    // proceed with remote integration\n} else {\n    eprintln!(\"{ref_name} has no upstream; skipping remote steps\");\n}","handlingStrategy":"fallback","validationCode":"fn has_upstream(repo: &Repo, ref_name: &str) -> bool {\n    repo.config().branch(ref_name).map(|b| b.remote.is_some()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match repo.resolve_tracking_branch_ref_name(ref_name) {\n    Ok(remote) => use_remote(remote),\n    Err(_) => skip_remote_integration(),\n}","preventionTips":["Run git push -u or set upstream when creating branches","Audit branch.<name>.remote config entries before remote operations","Treat upstream-less branches as local-only in tooling","Detect deleted remotes and clean up tracking config"],"tags":["git","branches","tracking"],"backgroundTag":"resource-not-found","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"}