{"record":{"id":"9b9184153cd2d099","repo":"gitbutlerapp/gitbutler","slug":"local-branch-not-found","errorCode":null,"errorMessage":"Local branch '{}' not found","messagePattern":"Local branch '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/branch/update.rs","lineNumber":138,"sourceCode":"                        commits: commits.into_iter().map(Into::into).collect(),\n                        message,\n                    }\n                }\n                but_workspace::branch::InteractiveIntegrationStep::Merge { commit_id } => {\n                    json::InteractiveIntegrationStep::Merge {\n                        commit_id: commit_id.into(),\n                    }\n                }\n            })\n            .collect(),\n    }\n}\n\nfn resolve_local_branch(ctx: &but_ctx::Context, branch: &str) -> anyhow::Result<FullName> {\n    let candidate = normalize_local_branch_ref(branch)?;\n    let repo = ctx.repo.get()?;\n    let Some(reference) = repo.try_find_reference(candidate.as_ref())? else {\n        bail!(\"Local branch '{}' not found\", candidate.shorten());\n    };\n    let reference = reference.detach();\n    match reference.name.category() {\n        Some(Category::LocalBranch) => Ok(reference.name),\n        Some(Category::RemoteBranch) => {\n            bail!(\n                \"Expected a local branch, but '{}' is a remote-tracking branch\",\n                reference.name.shorten()\n            )\n        }\n        _ => bail!(\n            \"Expected a local branch, but '{}' is not under refs/heads/\",\n            reference.name.shorten()\n        ),\n    }\n}\n\nfn normalize_local_branch_ref(branch: &str) -> anyhow::Result<FullName> {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/branch/update.rs#L120-L156","documentation":"`but branch update` resolves its target branch through resolve_local_branch, which first normalizes the name to a full ref and looks it up in the repository. This error is thrown when no reference with that name exists in the repo.","triggerScenarios":"Running `but branch update <name> ...` where try_find_reference returns None after normalizing to refs/heads/<name> — the branch doesn't exist locally (typo, never created, or only exists on a remote).","commonSituations":"Typos in branch names; branches that exist only as remote-tracking refs (origin/feature) and were never checked out locally; branches deleted locally but still pushed.","solutions":["Check the exact branch name with `but branch list` or `git branch`.","If it only exists on the remote, create it locally first (e.g. `git switch <branch>` or `git checkout -b <branch> origin/<branch>`).","Fix any typo and re-run the command."],"exampleFix":"// before\nbut branch update featuer-x --to abc123\n// after\nbut branch update feature-x --to abc123","handlingStrategy":"validation","validationCode":"const branches = execSync('git branch --list ' + shellEscape(name)).toString().trim();\nif (!branches) throw new Error(`Local branch '${name}' does not exist; check 'git branch' before updating`);","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`but branch update ${name} --to ${sha}`, { stdio: 'inherit' });\n} catch (err) {\n  if (String(err).includes('not found')) {\n    console.error(`Branch ${name} not found; run 'git branch' to list local branches`);\n  } else { throw err; }\n}","preventionTips":["List local branches (`git branch` / `but branch list`) before scripting updates.","Remember remote-only branches are invisible to this command; check out locally first.","Use shell completion or copy branch names from tooling output to avoid typos."],"tags":["git","branch","not-found","cli"],"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"}