gitbutlerapp/gitbutler · error
Branch ' ' has no tracking branch
Error message
Branch '{ref_name}' has no tracking branch What it means
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.
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
Example fix
// before
let remote = repo.resolve_tracking_branch_ref_name(ref_name)?;
// after
if let Ok(remote) = repo.resolve_tracking_branch_ref_name(ref_name) {
// proceed with remote integration
} else {
eprintln!("{ref_name} has no upstream; skipping remote steps");
} Defensive patterns
Strategy: fallback
Validate before calling
fn has_upstream(repo: &Repo, ref_name: &str) -> bool {
repo.config().branch(ref_name).map(|b| b.remote.is_some()).unwrap_or(false)
} Try / catch
match repo.resolve_tracking_branch_ref_name(ref_name) {
Ok(remote) => use_remote(remote),
Err(_) => skip_remote_integration(),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not turn into a valid reference name
- Aborting due to empty branch name
- Ad-hoc (single-branch) branch moves are not supported…
- An octopus merge commits must have at least two parents
- another pre-commit hook is already using the repository…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/567a4ee8b1a1a89e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-core/src/branch/mod.rs:63
.map(|reference| {
reference.map(|_| {
full_name
.try_into()
.expect("constructed remote-tracking refname must be valid")
})
})
})
.collect::<Result<Vec<gix::refs::FullName>, _>>()?;
if remote_matches.len() == 1 {
return Ok(Cow::Owned(
remote_matches
.pop()
.expect("exactly one remote match exists"),
));
}
bail!("Branch '{ref_name}' has no tracking branch")
}
/// A way to safely delete branches, which is only the case it's checked out nowhere.
pub mod safe_delete;
/// State for reuse when [safely deleting references](SafeDelete::delete_reference).
#[derive(Debug)]
pub struct SafeDelete {
/// A mapping of one or more worktree paths that are affected by changes to the keyed reference name.
worktrees_by_ref: WorktreePathByRef,
}
View on GitHub (pinned to 58e5313667)