What command is used to create a tag?
Posted by HenryPk
Last Updated: June 06, 2024
To create a tag in Git, you can use the following command:
git tag <tag_name>
For example:
git tag v1.0
If you want to create an annotated tag, which is recommended for releases because it includes additional metadata (like the tagger's name, email, and date), you can use the -a option:
git tag -a <tag_name> -m "Tag message"
For example:
git tag -a v1.0 -m "Release version 1.0"
You can also tag a specific commit by adding the commit hash at the end of the command:
git tag -a <tag_name> <commit_hash> -m "Tag message"
After creating a tag, if you want to push your tags to the remote repository, you can use:
git push origin <tag_name>
Or push all tags at once:
git push origin --tags