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.

Solutions

  1. Open the repository containing the file as a project worktree
  2. 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@916fc2b8cb (2026-08-20). Data as JSON: /api/errors/cd8005e5067a18f9. Report an issue: GitHub.

Appendix: source

Thrown at crates/project/src/git_store.rs:2120

        let is_unmerged = self
            .repository_and_path_for_buffer_id(buffer_id, cx)
            .is_some_and(|(repo, path)| repo.read(cx).snapshot.has_conflict(&path));
        let git_store = cx.weak_entity();
        let buffer_git_state = self
            .diffs
            .entry(buffer_id)
            .or_insert_with(|| cx.new(|cx| BufferGitState::new(git_store, cx)));
        let conflict_set = cx.new(|cx| ConflictSet::new(buffer_id, is_unmerged, cx));

        self._subscriptions
            .push(cx.subscribe(&conflict_set, |_, _, _, cx| {
                cx.emit(GitStoreEvent::ConflictsUpdated);
            }));

        let rx = buffer_git_state.update(cx, |state, cx| {
            state.conflict_set = Some(conflict_set.downgrade());
            let buffer_snapshot = buffer.read(cx).text_snapshot();
            state.reparse_conflict_markers(buffer_snapshot, cx)
        });

        cx.spawn(async move |_, _| {
            rx.await.ok();
            conflict_set
        })
    }

    pub fn project_path_git_status(
        &self,
        project_path: &ProjectPath,
        cx: &App,
    ) -> Option<FileStatus> {
        let (repo, repo_path) = self.repository_and_path_for_project_path(project_path, cx)?;
        Some(repo.read(cx).status_for_path(&repo_path)?.status)
    }

View on GitHub (pinned to 916fc2b8cb)