{"record":{"id":"f8fcc37c19bb8e60","repo":"gitbutlerapp/gitbutler","slug":"could-not-find-commit-commit-id","errorCode":null,"errorMessage":"Could not find commit {commit_id}","messagePattern":"Could not find commit (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/id/mod.rs","lineNumber":1804,"sourceCode":"    pub fn stacks(&self) -> &Vec<StackWithId> {\n        self.indexed_stacks.borrow_owner()\n    }\n\n    /// Get a distinct commit by ID.\n    ///\n    /// Errors if the commit cannot be found or if there are multiple matches.\n    pub fn get_commit_by_id(&self, commit_id: gix::ObjectId) -> anyhow::Result<CommitWithId<'_>> {\n        let mut matches = self\n            .commits()\n            .filter(|commit_with_id| match commit_with_id {\n                CommitWithId::Local(commit) => commit.commit_id() == commit_id,\n                CommitWithId::Remote(commit) => commit.commit_id() == commit_id,\n            });\n\n        match (matches.next(), matches.next()) {\n            (Some(commit), None) => Ok(commit),\n            (Some(_), Some(_)) => Err(anyhow::anyhow!(\"Found multiple matches for {commit_id}\")),\n            _ => Err(anyhow::anyhow!(\"Could not find commit {commit_id}\")),\n        }\n    }\n\n    fn commits(&self) -> impl Iterator<Item = CommitWithId<'_>> {\n        let stack_commits = self.indexed_stacks.borrow_owner().iter().flat_map(|stack| {\n            stack.segments.iter().flat_map(|segment| {\n                segment\n                    .workspace_commits\n                    .iter()\n                    .map(CommitWithId::Local)\n                    .chain(segment.remote_commits.iter().map(CommitWithId::Remote))\n            })\n        });\n\n        stack_commits.chain(\n            // Commits owned by a linked worktree resolve exactly like workspace commits - they\n            // just live outside the stacks.\n            self.worktrees","sourceCodeStart":1786,"sourceCodeEnd":1822,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/id/mod.rs#L1786-L1822","documentation":"This is the fallback branch of the same commit lookup: when the iterator over indexed stack commits yields no match for the requested `commit_id`, the resolver reports that the commit cannot be found in the current workspace state.","triggerScenarios":"Resolving a commit id that exists in the repository's object database but not in any indexed stack — e.g., referencing an already-pushed-and-removed commit, a commit on an unassigned branch, a typo'd/short id, or querying before the workspace index was refreshed.","commonSituations":"Using a commit id from `git log` that GitButler no longer manages; referring to a commit whose branch was unapplied; stale CLI state after another process changed the workspace; abbreviated hash that doesn't correspond to a managed commit.","solutions":["Run `but status` (or the log TUI) to list currently managed commit ids and use one of those.","If the commit should be managed, apply/assign its branch to the workspace so it is indexed, then retry.","Verify the id is correct (copy the full or abbreviated hash from the intended commit) and refresh workspace state before retrying."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before resolving, confirm the id is among managed commits\nif !managed_commit_ids().contains(&commit_id) {\n    eprintln!(\"{} is not managed by the workspace\", commit_id);\n}","typeGuard":null,"tryCatchPattern":"match workspace.find_commit(commit_id) {\n    Err(e) if e.to_string().contains(\"Could not find commit\") => {\n        eprintln!(\"Run `but status` for managed ids; apply the branch if needed\");\n    }\n    other => other?,\n}","preventionTips":["Copy commit ids from `but status` / the GitButler log, not raw `git log`.","Ensure the owning branch is applied to the workspace before referencing its commits.","Use full or sufficiently long hashes to avoid abbreviation ambiguity."],"tags":["git","commit-lookup","not-found"],"backgroundTag":"record-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"}