New-GitTag

Creates a new tag in a Git repository.

Syntax

New-GitTag [[-RepoRoot] <String>] [-Name] <String> [[-Revision] <String>] [-Force] [<CommonParameters>]

Description

The New-GitTag function creates a tag in a Git repository.

A tag is a name that references/points to a specific commit in the repository. By default, the tag points to the commit checked out in the working directory. To point to a specific commit, pass the commit ID to the Target parameter.

If the tag already exists, this function will fail. If you want to update an existing tag to point to a different commit, use the Force switch.

This function implements the git tag <tagname> <target> command.

Parameters

Name Type Description Required? Pipeline Input Default Value
RepoRoot String

Specifies which git repository to add the tag to. Defaults to the current directory.

false false (Get-Location).ProviderPath
Name String

The name of the tag.

true false
Revision String

The revision the tag should point to/reference. A revision can be a specific commit ID/sha (short or long), branch name, tag name, etc. Run git help gitrevisions or go to https://git-scm.com/docs/gitrevisions for full documentation on Git's revision syntax.

false false HEAD
Force SwitchParameter

Overwrite existing tag to point at new target

false false False

EXAMPLE 1

New-GitTag -Name 'BranchBaseline'

Creates a new tag, BranchBaseline, for the HEAD of the current directory.

EXAMPLE 2

New-GitTag -Name 'BranchBaseline' -Target 'branch'

Demonstrates how to create a tag pointing to the head of a branch.

EXAMPLE 3

New-GitTag -Name 'BranchBaseline' -Force

Demonstrates how to change the target a tag points to, to the current HEAD.