Get-GitBranch

Gets the branches in a Git repository.

Syntax

Get-GitBranch [[-RepoRoot] <String>] [-Current] [<CommonParameters>]

Description

The Get-GitBranch function returns a list of all the branches in a repository.

Use the Current switch to return just the current branch.

It defaults to the current repository. Use the RepoRoot parameter to specify an explicit path to another repo.

Parameters

Name Type Description Required? Pipeline Input Default Value
RepoRoot String

Specifies which git repository to check. Defaults to the current directory.

false false (Get-Location).ProviderPath
Current SwitchParameter

Get the current branch only. Otherwise all branches are returned.

false false False

Return Values

LibGit2.Automation.BranchInfo.

EXAMPLE 1

Get-GitBranch -RepoRoot 'C:\Projects\LibGit2' -Current

Returns an object representing the current branch for the specified repo.

EXAMPLE 2

Get-GitBranch

Returns objects for all the branches in the current directory.