Skip to main content

Module path

Module path 

Source
Expand description

Repository path discovery.

Functions§

git_common_dir
Path to the shared .git directory of the repository containing cwd. Equivalent to git_dir in repos without linked worktrees; in worktree-having repos it always returns the main .git/ rather than the per-worktree subtree.
git_dir
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.
lfs_alternate_dirs
LFS-objects directories belonging to alternate object stores referenced by this repository. Used to satisfy a git lfs smudge or git lfs fetch from a git clone --shared <source> checkout without re-downloading bytes the source already has.
lfs_dir
Path to the LFS storage directory (<common-git-dir>/lfs). The directory is not created. Routed through git_common_dir so a linked worktree shares the same on-disk LFS object cache as its main repo — git lfs prune from one worktree sees the same 100% of objects as git lfs fetch from another.
work_tree_root
Path to the working-tree root of the repository containing cwd. Honors GIT_WORK_TREE, so this returns the right thing even when cwd is outside the work tree (e.g. tests that set both GIT_DIR and GIT_WORK_TREE as relative paths from a parent dir). Errors for bare repos (no work tree) and outside-any-repo callers.