zed-industries/zed · error
failed to find a git repository for buffer
Error message
failed to find a git repository for buffer
What it means
In Project::blame_buffer: repository_and_path_for_buffer_id returned None, meaning the buffer's file is not tracked by any git repository known to this project's GitStore. Blame cannot be computed for files outside a repository.
Source
Thrown at crates/project/src/git_store.rs:2114
Ok(future::try_join_all(tasks)
.await?
.into_iter()
.all(|result| result))
})
}
/// Blames a buffer.
pub fn blame_buffer(
&self,
buffer: &Entity<Buffer>,
version: Option<clock::Global>,
cx: &mut Context<Self>,
) -> Task<Result<Option<Blame>>> {
let buffer = buffer.read(cx);
let Some((repo, repo_path)) =
self.repository_and_path_for_buffer_id(buffer.remote_id(), cx)
else {
return Task::ready(Err(anyhow!("failed to find a git repository for buffer")));
};
let content = match &version {
Some(version) => buffer.rope_for_version(version),
None => buffer.as_rope().clone(),
};
let line_ending = buffer.line_ending();
let version = version.unwrap_or(buffer.version());
let buffer_id = buffer.remote_id();
let repo = repo.downgrade();
cx.spawn(async move |_, cx| {
let repository_state = repo
.update(cx, |repo, _| repo.repository_state.clone())?
.await
.map_err(|err| anyhow::anyhow!(err))?;
match repository_state {
RepositoryState::Local(LocalRepositoryState { backend, .. }) => backend
.blame(repo_path.clone(), content, line_ending)View on GitHub (pinned to f4178619ac)
Solutions
- Open the repository containing the file as a project worktree
- Ensure the worktree's git repo has been discovered (check for .git and worktree indexing)
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/project/src/git_store.rs:2114 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/cd8005e5067a18f9.
Report an issue: GitHub.