gitbutlerapp/gitbutler · error

Commit ' ' not found

Error message

Commit '{commit_id_str}' not found

What it means

`show_commit` resolves a user-supplied CLI id: when no matches exist in the IdMap it falls back to `rev_parse_single` on the git object database. This error is returned when git's rev-parse cannot resolve the given string to any object, meaning the commit id (or other CLI id) does not exist in the repository.

Solutions

  1. re-run `but status` and use a current CLI id from the output
  2. verify the id resolves with `git rev-parse <id>` in the same repository
  3. check you are in the same repository the id came from

Example fix

// before
but show abc123d   # id from an old session
// after
but status          # refresh CLI ids
but show <fresh-id>
Defensive patterns

Strategy: validation

Validate before calling

if !id_map_contains(id) && Command::new("git").args(["rev-parse","--verify",id]).output().map(|o| !o.status.success()).unwrap_or(true) {
    eprintln!("id {id} does not resolve; refresh with `but status`");
}

Try / catch

match show_commit(ctx, id) {
    Err(e) if e.to_string().contains("not found") => {
        eprintln!("Stale or unknown id '{id}'; re-run `but status`.");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `but show <id>` where `<id>` is not in the IdMap and is not a resolvable git revision: a deleted/garbage-collected commit, a truncated or mistyped hash, an id from another repository/branch, or a stale CliId copied earlier.

Common situations: Copying a commit id from another checkout, referencing a commit that was rebased/squashed away, typos in a short hash, or using a CLI id after a workspace rebase invalidated it.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/5fe147350b925be0. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/legacy/show.rs:60

            let head_name = branch.name.clone();
            if head_name == commit_id_str
                || head_name.to_lowercase() == commit_id_str.to_lowercase()
            {
                // Found the branch in a stack
                return show_branch(ctx, out, &head_name, verbose, &id_map);
            }
        }
    }

    // Not a branch, resolve the commit ID through the IdMap
    let cli_ids = id_map.parse_using_context(commit_id_str, ctx)?;

    let commit_id = if cli_ids.is_empty() {
        // If not found in IdMap, try to parse as a git commit ID directly
        let repo = ctx.repo.get()?;
        let obj = repo
            .rev_parse_single(commit_id_str)
            .map_err(|_| anyhow::anyhow!("Commit '{commit_id_str}' not found"))?;
        let commit = obj
            .object()?
            .try_into_commit()
            .map_err(|_| anyhow::anyhow!("'{commit_id_str}' is not a commit"))?;
        commit.id
    } else if cli_ids.len() > 1 {
        bail!(
            "Commit ID '{}' is ambiguous. Found {} matches",
            commit_id_str,
            cli_ids.len()
        );
    } else {
        match &cli_ids[0] {
            CliId::Commit {
                commit: CommitId { commit_id, .. },
                id: _,
            } => *commit_id,
            CliId::Branch(branch) => {

View on GitHub (pinned to 58e5313667)