Skip to content

Get‑GitTag

viscalyxbot edited this page Sep 30, 2025 · 1 revision

SYNOPSIS

Retrieves Git tags based on specified parameters.

SYNTAX

First (Default)

Get-GitTag [[-Name] <String>] [-First <UInt32>] [-AsVersions] [-Descending]
 [<CommonParameters>]

Latest

Get-GitTag [-Latest] [<CommonParameters>]

DESCRIPTION

The Get-GitTag function retrieves Git tags based on the specified parameters. It can retrieve the latest tag, a specific tag by name, or a list of tags. The function supports sorting and filtering options.

EXAMPLES

EXAMPLE 1

Get-GitTag -Name 'v1.0'

Retrieves the Git tag with the name 'v1.0'.

EXAMPLE 2

Get-GitTag -Latest

Retrieves the latest Git tag.

EXAMPLE 3

Get-GitTag -Name 'v13*' -AsVersions -Descending

Retrieves all Git tags as versions that start with 'v13', and sort them in descending order.

EXAMPLE 4

Get-GitTag -First 5 -AsVersions -Descending

Retrieves the first 5 Git tags as version numbers after the tags are sorted in descending order.

PARAMETERS

-AsVersions

Specifies whether to retrieve tags as version numbers. This parameter is used in the 'First' parameter set.

Type: SwitchParameter
Parameter Sets: First
Aliases:

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

-Descending

Specifies whether to sort the tags in descending order. This parameter is used in the 'First' parameter set. Default is ascending order.

Type: SwitchParameter
Parameter Sets: First
Aliases:

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

-Latest

Retrieves the latest Git tag. This parameter is used in the 'Latest' parameter set.

Type: SwitchParameter
Parameter Sets: Latest
Aliases:

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

-Name

Specifies the name of the tag to retrieve. This parameter is used in the 'First' parameter set.

Type: String
Parameter Sets: First
Aliases:

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

-First

Specifies the number of tags to retrieve. This parameter is used in the 'First' parameter set.

Type: UInt32
Parameter Sets: First
Aliases:

Required: False
Position: Named
Default value: 0
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

The retrieved Git tag(s).

NOTES

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

RELATED LINKS

Clone this wiki locally