Creating a tag for a commit in Git

Create a tag for a commit in Git. Last updated: 2018-12-19

Create a tag for a commit :

# Create a tag "v1.0" for HEAD.
$ git tag v1.0

# Create an annotated tag for HEAD with "-a" option.
# -a, this is an annotated tag which can include other information in an object, 
#     such as message, name, email
$ git tag -a v1.0 -m "Formal version v1.0"

# Create a tag for commit "06d49a9"
$ git tag v1.0 06d49a9

Note: By default, git push does not push tags to the remote repository, you need to explicitly push them:

# Push a tag "v1.0" to remote repository
$ git push v1.0

# Push all tags to remote repository
$ git push --tags