zed-industries/zed · error

failed to find git repository for buffer

Error message

failed to find git repository for buffer

What it means

A git operation on a buffer could not map the buffer to any repository: repository_and_path_for_buffer_id found no git repo containing that buffer's file. The file is outside all known worktree repos (or the repo has not been indexed yet).

Solutions

  1. Verify the file belongs to a folder opened as a worktree containing a .git directory
  2. If the repo was just added, wait for/git the worktree scan to complete and retry
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/project/src/git_store.rs:1205 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/9976da4a6bfc3612. Report an issue: GitHub.

Appendix: source

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

                                            let update =
                                                snapshot.build_update(old_snapshot, project_id);
                                            *old_snapshot = snapshot;
                                            for update in split_repository_update(update) {
                                                client.send(update)?;
                                            }
                                        } else {
                                            let update = snapshot.initial_update(project_id);
                                            for update in split_repository_update(update) {
                                                client.send(update)?;
                                            }
                                            snapshots.insert(snapshot.id, snapshot);
                                        }
                                    }
                                    DownstreamUpdate::RemoveRepository(id) => {
                                        client.send(proto::RemoveRepository {
                                            project_id,
                                            id: id.to_proto(),
                                        })?;
                                    }
                                }
                            }
                            anyhow::Ok(())
                        })
                        .await
                        .ok();
                        this.update(cx, |this, _| {
                            if let GitStoreState::Local {
                                downstream: downstream_client,
                                ..
                            } = &mut this.state
                            {
                                downstream_client.take();
                            } else {
                                unreachable!("unshared called on remote store");
                            }
                        })

View on GitHub (pinned to 916fc2b8cb)