Skip to main content

is_git_repo

Function is_git_repo 

Source
pub fn is_git_repo(path: &Path) -> bool
Expand description

Check whether path is inside a git repository. Shells out to git rev-parse --git-dir. Exit 0 -> true; anything else -> false.

Handles every git-recognised shape (normal repo, submodule, worktree-in-worktree, detached HEAD, bare repo) by reading git’s own answer rather than re-implementing detection. Non-existent paths return false because git itself errors on them.