Skip to main content

get_current_branch

Function get_current_branch 

Source
pub fn get_current_branch() -> Option<String>
Expand description

Get the current git branch, using cache if available.

Returns None if not on a named branch (detached HEAD) or not in a git repo. Use get_branch_info for more detailed information.

ยงCaching

Results are cached per working directory for up to 30 seconds to avoid repeated subprocess calls. The cache is automatically invalidated when the working directory changes.