Skip to main content

git_dir

Function git_dir 

Source
pub fn git_dir(cwd: &Path) -> Result<PathBuf, Error>
Expand description

Path to the per-worktree .git directory of the repository containing cwd. Always returns an absolute path. Errors if cwd isn’t inside a git repository.

In a linked worktree this is .git/worktrees/<name>/, not the shared main .git/. Use this when you want per-worktree state (HEAD, index, info/, hooks-when---worktree-scoped). For shared storage (objects, packs, LFS cache, alternates), use git_common_dir.