Git tags are useful for marking specific points in the repository's history, such as releases. They act like milestones, allowing you to reference a particular commit easily. This tutorial demonstrates how to create Git tags.
Git provides two types of tags: lightweight and annotated. Lightweight tags act as simple references to specific commits, functioning like bookmarks. In contrast, annotated tags are stored as complete objects in the Git database, containing metadata such as the tagger's name, email, date, and a tagging message.
1. Lightweight tag
To create a lightweight tag, use the git tag
command followed by the desired tag name:
git tag v1.0
To confirm that Git tag was created successfully, run the git tag
command to list all existing tags:
git tag
2. Annotated tag
To create an annotated tag, use the git tag
command with the -a
option and the -m
option to add a message:
git tag -a v1.0 -m "New release"
3. Push tag to remote
By default, the git push
command does not include tags when pushing to a remote repository. To share the tag with others, push it with command:
git push origin v1.0
4. Push all tags to remote
If you have multiple tags and want to push them all at once to a remote repository, use:
git push origin --tags
Leave a Comment
Cancel reply