Expand description
Repository path discovery.
Functions§
- git_
common_ dir - Path to the shared
.gitdirectory of the repository containingcwd. Equivalent togit_dirin 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
.gitdirectory of the repository containingcwd. Always returns an absolute path. Errors ifcwdisn’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 smudgeorgit lfs fetchfrom agit 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 throughgit_common_dirso a linked worktree shares the same on-disk LFS object cache as its main repo —git lfs prunefrom one worktree sees the same 100% of objects asgit lfs fetchfrom another. - work_
tree_ root - Path to the working-tree root of the repository containing
cwd. HonorsGIT_WORK_TREE, so this returns the right thing even whencwdis outside the work tree (e.g. tests that set bothGIT_DIRandGIT_WORK_TREEas relative paths from a parent dir). Errors for bare repos (no work tree) and outside-any-repo callers.