Skip to content

Get‑GitRemoteBranch

viscalyxbot edited this page Sep 30, 2025 · 1 revision

SYNOPSIS

Retrieves the names of remote Git branches.

SYNTAX

Default (Default)

Get-GitRemoteBranch [[-RemoteName] <String>] [-RemoveRefsHeads] 
 [<CommonParameters>]

Name

Get-GitRemoteBranch [-RemoteName] <String> [[-Name] <String>] [-RemoveRefsHeads]
 [<CommonParameters>]

DESCRIPTION

The Get-GitRemoteBranch command retrieves the names of remote Git branches from the specified remote repository. It supports filtering by branch name patterns and can optionally remove the 'refs/heads/' prefix from branch names.

EXAMPLES

EXAMPLE 1

Get-GitRemoteBranch -RemoteName 'origin'

Retrieves all remote branches from the 'origin' remote repository.

EXAMPLE 2

Get-GitRemoteBranch -RemoteName 'origin' -Name 'feature/*'

Retrieves all remote branches from 'origin' that match the pattern 'feature/*'.

EXAMPLE 3

Get-GitRemoteBranch -RemoteName 'origin' -Name 'main' -RemoveRefsHeads

Retrieves the 'main' branch from 'origin' with the 'refs/heads/' prefix removed.

PARAMETERS

-Name

Specifies the name or pattern of the branch to retrieve. Supports wildcard patterns.

Type: String
Parameter Sets: Name
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RemoteName

Specifies the name of the remote repository to query for branches. If not provided, uses the default remote.

Type: String
Parameter Sets: Default
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: Name
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RemoveRefsHeads

When specified, removes the 'refs/heads/' prefix from the returned branch names.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None

This function does not accept pipeline input.

OUTPUTS

System.String

Returns the names of remote branches matching the specified criteria.

NOTES

This function requires Git to be installed and accessible from the command line.

RELATED LINKS

Clone this wiki locally