How to create tag in GIT


To create a tag in Git, you can use the git tag command followed by the tag name. Here’s an example:

Assume you want to create a new tag called v1.0 for the current commit:

git tag v1.0

This will create a new lightweight tag at the current commit with the name v1.0. Note that this tag will not have any additional information such as a tag message or a signature.

If you want to create an annotated tag with additional information such as a tag message or a signature, you can use the -a option:

git tag -a v1.0 -m "Release version 1.0"

This will create a new annotated tag with the name v1.0 at the current commit, with the tag message “Release version 1.0”.

If you want to create a tag for a specific commit other than the current one, you can specify the commit hash:

git tag v1.0 <commit-hash>

This will create a new tag at the commit with the specified hash.

After creating a tag, you can list all tags in the repository by running:

git tag

To push a tag to a remote repository, you can use the git push command with the --tags option:

git push --tags

This will push all tags in the repository to the remote repository. If you want to push a specific tag, you can specify the tag name:

git push origin v1.0

This will push the tag with the name v1.0 to the remote repository.

That’s it! These are some examples of how to create and work with tags in Git.