{"record":{"id":"76f4028215ae35b8","repo":"gitbutlerapp/gitbutler","slug":"target-is-neither-a-commit-nor-a-branch-try-running-but","errorCode":null,"errorMessage":"\"{target}\" is neither a commit nor a branch. Try running 'but status' to see what is available.","messagePattern":"\"(.+?)\" is neither a commit nor a branch\\. Try running 'but status' to see what is available\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":708,"sourceCode":"        .len();\n    Ok(Some(ConflictTarget {\n        commit_oid,\n        branch,\n        other_conflicted,\n    }))\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,","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L690-L726","documentation":"Thrown by parse_commit_or_branch when the IdMap lookup for the user-supplied target returns no matches, i.e. the string is neither recognizable as a commit nor as a branch in the current workspace. The message redirects the user to `but status` to discover valid identifiers.","triggerScenarios":"`but resolve <target> ...` where <target> matches zero CliIds in the context IdMap — an unknown commit hash prefix, nonexistent branch, or a reference from outside the workspace.","commonSituations":"Typos, stale branch names after rebases, using a full SHA that is not reachable in the workspace, or referencing an identifier only valid in another repo.","solutions":["Run `but status` to list valid commit/branch identifiers.","Copy the exact identifier from the status output.","Check for typos or truncated hashes."],"exampleFix":"// before\nbut resolve feat/auhtorization\n// after\nbut resolve feat/authorization","handlingStrategy":"validation","validationCode":"const ids = parseStatusOutput(runButStatus());\nif (!ids.commits.some(c => c.startsWith(target)) && !ids.branches.includes(target)) {\n  throw new Error(`\"${target}\" is neither a commit nor a branch`);\n}","typeGuard":"const isCommitOrBranch = (id: string, ids: CliId[]) => ids.some(i => (i.kind === 'commit' || i.kind === 'branch') && i.matches(id));","tryCatchPattern":"try { await butResolve(target) } catch (e) { if (String(e).includes('neither a commit nor a branch')) { print(runButStatus()); } }","preventionTips":["Run `but status` first and copy identifiers verbatim.","Use full branch names rather than guesses.","Avoid referencing commits from outside the workspace."],"tags":["cli","git","invalid-argument","not-found"],"backgroundTag":"invalid-argument-value","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"}