{"record":{"id":"b1537bdb2bb9a6a1","repo":"gitbutlerapp/gitbutler","slug":"target-does-not-refer-to-a-commit-or-a-branch","errorCode":null,"errorMessage":"\"{target}\" does not refer to a commit or a branch","messagePattern":"\"(.+?)\" does not refer to a commit or a branch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":713,"sourceCode":"    }))\n}\n\nenum CommitOrBranch {\n    Commit(gix::ObjectId),\n    Branch(String),\n}\n\n/// Resolve a user-provided identifier to a commit or a branch.\nfn parse_commit_or_branch(ctx: &mut Context, target: &str) -> Result<CommitOrBranch> {\n    let id_map = IdMap::legacy_new_from_context(ctx)?;\n    let matches = id_map.parse_using_context(target, ctx)?;\n    match matches.as_slice() {\n        [] => bail!(\n            \"\\\"{target}\\\" is neither a commit nor a branch. Try running 'but status' to see what is available.\"\n        ),\n        [CliId::Commit { commit, .. }] => Ok(CommitOrBranch::Commit(commit.commit_id)),\n        [CliId::Branch(branch)] => Ok(CommitOrBranch::Branch(branch.name.clone())),\n        [_] => bail!(\"\\\"{target}\\\" does not refer to a commit or a branch\"),\n        _ => bail!(\n            \"\\\"{target}\\\" is ambiguous. Please provide more characters to uniquely identify it.\"\n        ),\n    }\n}\n\n/// List the conflicts of a conflicted commit without entering resolution mode.\nfn list_conflicts(ctx: &mut Context, out: &mut OutputChannel, commit: Option<&str>) -> Result<()> {\n    let t = theme::get();\n    let Some(target) = target_conflicted_commit(ctx, commit)? else {\n        if let Some(human_out) = out.for_human() {\n            writeln!(\n                human_out,\n                \"{}\",\n                t.success.paint(\"No conflicted commits found.\")\n            )?;\n        }\n        if let Some(json_out) = out.for_json() {","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L695-L731","documentation":"Thrown by parse_commit_or_branch when the IdMap matched exactly one CliId, but that id is neither a Commit nor a Branch (e.g. a file/htag/hunk id). The target resolves to something in the workspace, just not an entity that can carry conflicts.","triggerScenarios":"Passing a filename, hunk marker, or other non-commit/non-branch CliId as the conflict target to `but resolve`.","commonSituations":"Users paste a file path or hunk reference (like in `but resolve file.rs`) when the command in this position expects a commit or branch identifier.","solutions":["Run `but status` and use a commit or branch identifier instead.","If the goal is to resolve a file, pass the path in the path/hunk argument position, not as the commit target."],"exampleFix":"// before\nbut resolve src/main.rs\n// after\nbut resolve abc123 src/main.rs","handlingStrategy":"type-guard","validationCode":"const matched = idMap.parse(target);\nif (matched.length === 1 && matched[0].kind !== 'commit' && matched[0].kind !== 'branch') {\n  throw new Error('target must be a commit or branch, not ' + matched[0].kind);\n}","typeGuard":"const isCommit = (id: CliId): id is CommitCliId => id.kind === 'commit';\nconst isBranch = (id: CliId): id is BranchCliId => id.kind === 'branch';","tryCatchPattern":"try { await butResolve(target) } catch (e) { if (String(e).includes('does not refer to a commit or a branch')) { hint('pass a commit or branch id; the path goes as a separate argument'); } }","preventionTips":["Remember argument order: commit/branch target first, file path second.","Never pass file paths or hunk ids as the commit target.","Check id kind in `but status` output."],"tags":["cli","git","type-mismatch","invalid-argument"],"backgroundTag":"type-mismatch","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"}