gitbutlerapp/gitbutler · error
remote branch ' ' not found
Error message
remote branch '{target_branch_ref}' not found What it means
`set_base_branch` in gitbutler-branch-actions looks up the requested target/base branch as a reference in the repository. When `try_find_reference` returns None (branch ref does not exist locally), this anyhow error names the missing ref.
Solutions
- Fetch first: `git fetch origin`, then retry setting the base branch.
- Verify the branch exists: `git branch -a --list <name>` and use the exact full ref name.
- If the remote branch was deleted, choose an existing base or restore it on the remote.
- Check for typos and remote name mismatch (origin vs upstream).
Example fix
// before
set_base_branch("origin/featur")
// after
git fetch origin
set_base_branch("origin/feature") Defensive patterns
Strategy: validation
Validate before calling
if (!repo.try_find_reference(target_branch_ref)?) {
run('git fetch --all --prune');
if (!repo.try_find_reference(target_branch_ref)?) die(`branch ${target_branch_ref} does not exist locally`);
} Try / catch
match set_base_branch(ctx, target_branch_ref) {
Err(e) if e.to_string().contains("not found") => {
repo.fetch(all_remotes)?;
set_base_branch(ctx, target_branch_ref)
}
other => other,
} Prevention
- Fetch remotes before setting base branches.
- Validate branch names against `git branch -a` output.
- Watch for deleted upstream branches in CI scripts.
When it happens
Trigger: Calling set_base_branch with a target_branch_ref that has no local ref — a remote branch name that was never fetched, a deleted branch, or a name with wrong remote prefix.
Common situations: Setting base to `origin/feature` after the remote branch was deleted; referencing a remote that has never been fetched; typo in branch name; case-sensitivity mismatch.
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
- branch ' ' no longer exists
- BranchNotFound
- Branch ' ' already exists
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/a84d72c68beee001.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-branch-actions/src/base.rs:183
.as_ref()
.is_some_and(|target_ref| target_branch_ref == target_ref.as_ref());
(
workspace_ref_exists && project_meta.target_commit_id.is_some() && target_ref_matches,
project_meta.target_ref,
)
} else {
(false, None)
};
// if target exists, and it is the same as the requested branch, we should go back
if existing_target_ref_matches {
return go_back_to_integration(ctx, perm);
}
// lookup a branch by name
let mut target_branch = repo
.try_find_reference(target_branch_ref.to_string().as_str())?
.ok_or(anyhow!("remote branch '{target_branch_ref}' not found"))?;
let target_branch_head = target_branch
.peel_to_commit()
.context(format!(
"failed to peel branch {target_branch_ref} to commit"
))?
.id;
let mut current_head = repo.head().context("Failed to get HEAD reference")?;
let current_head_commit = current_head
.peel_to_commit()
.context("Failed to peel HEAD reference to commit")?
.id;
// calculate the commit as the merge-base between HEAD in ctx and this target commit
let target_commit_oid = but_workspace::init::resolve_target_commit(
&repo,
current_head_commit,View on GitHub (pinned to 58e5313667)