createTag()
Creates a lightweight Git tag.Syntax
Parameters
The name of the tag to create.Examples:
"v1.0.0", "hotfix-1"Configuration options.
Returns
A promise that resolves with the command output.
Examples
Create a basic tag
Create with promise handling
Force replace an existing tag
createAnnotatedTag()
Creates an annotated Git tag with a message. Annotated tags are stored as full objects in Git and include the tagger name, email, date, and a message.Syntax
Parameters
The name of the tag to create.Examples:
"v1.0.0", "release-2024"The annotation message for the tag.Examples:
"Initial stable release", "Production release for 2024"Configuration options.
Returns
A promise that resolves with the command output.
Examples
Create an annotated tag
Create with promise handling
Force replace with new message
deleteTag()
Deletes a local Git tag.Syntax
Parameters
The name of the tag to delete.Examples:
"v1.0.0", "release-2024"Returns
A promise that resolves with the command output.
Examples
Delete a tag
Delete with promise handling
getTags()
Retrieves all Git tags from the current repository.Syntax
Parameters
Optional list of prefixes to remove or replace from the beginning of each tag.
Replacement value for matched prefixes.
Returns
A promise that resolves to an array of tag names.
Examples
Get all tags
Strip and replace prefixes
hasTag()
Checks whether a given Git tag exists.Syntax
Parameters
The tag name to check.
Returns
A promise that resolves to
true if the tag exists, otherwise false.Examples
Check if a tag exists
Conditional tag creation
Notes
- Works for lightweight tags
- Works for annotated tags
- Works for signed and unsigned tags
isValidTagName()
Determines whether a string is a valid and safe Git tag name.Syntax
Parameters
The tag name to validate.
Returns
Returns
true if the name is a valid Git tag name, otherwise false.Examples
Valid tag names
Invalid tag names
Validate before creating
Invalid Cases
This function follows Git reference naming rules and prevents tag names that would be rejected by Git or cause ambiguous behavior:- Empty strings
- Reserved name
@ - Names containing the sequence
@{ - Names ending with
.lockor. - Names starting or ending with
/ - Consecutive slashes (
//) - Parent or current directory references (
..,/., or segments starting with.) - Whitespace or forbidden characters (
~ ^ : ? * [ ] \)
Related
- tag() - Low-level tag function
- SemVer Tags - Work with semantic version tags