Skip to main content

is_in_worktree

Function is_in_worktree 

Source
pub async fn is_in_worktree() -> Result<bool>
Expand description

Check if the current directory is inside a git worktree.

A worktree is detected by checking if .git is a file (not a directory). In a regular repo, .git is a directory; in a worktree, it’s a file containing a pointer to the main repo’s git directory.

§Errors

Returns an error if the .git path cannot be accessed.