nikivdev/code · error
not a git repository: {}
Error message
not a git repository: {} What it means
home_branch_repo_status (gathering per-repo home-branch status) canonicalizes repo_root and verifies a `.git` entry exists; if not, it bails with this message including the path. The function only works on actual git repositories.
Source
Thrown at src/repos.rs:1061
}
fn repo_home_branch_status(
repo_root: &Path,
requested_home_branch: &str,
) -> Result<HomeBranchRepoStatus> {
repo_home_branch_status_with_options(repo_root, requested_home_branch, true)
}
fn repo_home_branch_status_with_options(
repo_root: &Path,
requested_home_branch: &str,
include_private_mirror_status: bool,
) -> Result<HomeBranchRepoStatus> {
let repo_root = repo_root
.canonicalize()
.unwrap_or_else(|_| repo_root.to_path_buf());
if !repo_root.join(".git").exists() {
bail!("not a git repository: {}", repo_root.display());
}
let current_branch = git_capture_in(&repo_root, &["branch", "--show-current"])
.unwrap_or_else(|_| "HEAD".to_string());
let configured_home_branch = config::configured_home_branch_for_repo(&repo_root);
let home_branch = configured_home_branch
.clone()
.unwrap_or_else(|| requested_home_branch.to_string());
let configured_public_remote = config::configured_public_remote_for_repo(&repo_root);
let origin_url = git_config_get(&repo_root, "remote.origin.url");
let upstream_url = git_config_get(&repo_root, "remote.upstream.url");
let fork_remote_url = git_config_get(&repo_root, "remote.fork.url");
let public_remote = resolve_public_remote_name(
configured_public_remote.as_deref(),
origin_url.as_deref(),
upstream_url.as_deref(),
);
let public_default_branch = public_remoteView on GitHub (pinned to a747e741ae)
Solutions
- Point the operation at the actual repository root containing `.git`.
- Re-clone the repository if it was deleted.
- Verify path configuration for that repo entry (typos, stale paths).
Example fix
// before
status_for(Path::new("~/projects")) // parent dir, no .git
// after
status_for(Path::new("~/projects/myrepo")) Defensive patterns
Strategy: validation
Validate before calling
fn is_repo_root(dir: &std::path::Path) -> bool {
dir.join(".git").exists()
}
// call the status API only if is_repo_root(&repo_root) Try / catch
match home_branch_repo_status(&repo_root, ... ) {
Err(e) if e.to_string().contains("not a git repository") => {
eprintln!("{} is not a repo; skipping", repo_root.display());
}
r => r?,
} Prevention
- Verify configured repo paths point at directories containing `.git`.
- Re-check paths after moving, renaming, or deleting repositories.
- Pass the repo root, not a parent or subdirectory.
- Handle worktrees/bare clones separately since `.git` may be absent at the passed root.
When it happens
Trigger: Calling the status function on a directory lacking `.git` (plain folder, deleted repo, or a bare/worktree layout where `.git` is absent from the passed root).
Common situations: A configured repo path that was deleted or renamed; passing a subdirectory or parent of the repo instead of its root; repos converted to worktrees with the metadata elsewhere.
Related errors
- repo URL is required
- unable to parse GitHub repo from: {}
- handled before project context load
- jj git export retry loop should always return
- Lin.app is not running
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/fc7d889c2ea69b15.
Report an issue: GitHub.