{"record":{"id":"a84d72c68beee001","repo":"gitbutlerapp/gitbutler","slug":"remote-branch-target-branch-ref-not-found","errorCode":null,"errorMessage":"remote branch '{target_branch_ref}' not found","messagePattern":"remote branch '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-branch-actions/src/base.rs","lineNumber":183,"sourceCode":"            .as_ref()\n            .is_some_and(|target_ref| target_branch_ref == target_ref.as_ref());\n        (\n            workspace_ref_exists && project_meta.target_commit_id.is_some() && target_ref_matches,\n            project_meta.target_ref,\n        )\n    } else {\n        (false, None)\n    };\n\n    // if target exists, and it is the same as the requested branch, we should go back\n    if existing_target_ref_matches {\n        return go_back_to_integration(ctx, perm);\n    }\n\n    // lookup a branch by name\n    let mut target_branch = repo\n        .try_find_reference(target_branch_ref.to_string().as_str())?\n        .ok_or(anyhow!(\"remote branch '{target_branch_ref}' not found\"))?;\n\n    let target_branch_head = target_branch\n        .peel_to_commit()\n        .context(format!(\n            \"failed to peel branch {target_branch_ref} to commit\"\n        ))?\n        .id;\n\n    let mut current_head = repo.head().context(\"Failed to get HEAD reference\")?;\n    let current_head_commit = current_head\n        .peel_to_commit()\n        .context(\"Failed to peel HEAD reference to commit\")?\n        .id;\n\n    // calculate the commit as the merge-base between HEAD in ctx and this target commit\n    let target_commit_oid = but_workspace::init::resolve_target_commit(\n        &repo,\n        current_head_commit,","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-branch-actions/src/base.rs#L165-L201","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nset_base_branch(\"origin/featur\")\n// after\ngit fetch origin\nset_base_branch(\"origin/feature\")","handlingStrategy":"validation","validationCode":"if (!repo.try_find_reference(target_branch_ref)?) {\n  run('git fetch --all --prune');\n  if (!repo.try_find_reference(target_branch_ref)?) die(`branch ${target_branch_ref} does not exist locally`);\n}","typeGuard":null,"tryCatchPattern":"match set_base_branch(ctx, target_branch_ref) {\n  Err(e) if e.to_string().contains(\"not found\") => {\n    repo.fetch(all_remotes)?;\n    set_base_branch(ctx, target_branch_ref)\n  }\n  other => other,\n}","preventionTips":["Fetch remotes before setting base branches.","Validate branch names against `git branch -a` output.","Watch for deleted upstream branches in CI scripts."],"tags":["git","branch","reference-lookup","missing-ref"],"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"}