To create a new Git tag, you can use the git tag
command followed by the tag name. For example, to create a lightweight tag named v1.0
, you can run the following command in your terminal:
git tag v1.0
To create an annotated tag, which includes additional metadata such as the tagger's name, email, and a tagging message, you can use the -a
(annotate) option:
git tag -a v1.0 -m "Release version 1.0"
To list all the tags in your repository, you can use the git tag
command without any arguments:
git tag
This will display a list of all the tags in your repository.
You can also use the --list
option to filter the tags by a specific pattern:
git tag --list 'v1.*'
This will list all the tags that start with v1.
.
As mentioned earlier, you can create annotated tags using the -a
option. To add or modify the annotation of an existing tag, you can use the -a
option again:
git tag -a v1.0 -m "Release version 1.0 (updated)"
This will update the annotation of the v1.0
tag with the new message.
You can also view the annotation of a tag using the git show
command:
git show v1.0
This will display the tag information, including the tagger's name, email, and the annotated message.
By understanding how to create, list, and annotate Git tags, you can effectively manage and track the evolution of your software project, making it easier to collaborate, deploy, and maintain your codebase.