All Courses
Git Tag

Git has the ability to mark certain points in history as important. Users typically use this feature to mark release points (such as v1.0). In this section, you will learn how to list the available Git Tag, how to create new tags and different types of tags.

Creating Tags:

Git supports two types of tags:

  • Lightweight
  • Annotated.

Annotated :

However, the annotated tag is stored in the Git database as a complete object. They are checksums that Include the tagger’s name, email address, and date. I have a tagging message. Creating annotated tags in Git is easy. The easiest way is to specify -a when running the tag command.

$ git tag -a v1.0 -m "my release version 1.0"
Git Tag - version

Check the list of tags used

$ git log

You can see the tag data along with the commits tagged with git show Instructions:

$ git show v1.0
Git Tag - latest version

Lightweight: Lightweight tags are very similar to unaltered branches. This is only one. A pointer to a specific commit.
This is basically a commit checksum stored in a file, no other information is stored. To create a lightweight tag, specify only the tag name, not the -a, -s, or -m options.

$ git tag v1.1
Git Tag - V1.1

Tagging Later:

Take hash code using git log
git tag v0.0.1 3f42f2d

You can also mark a commit after it has passed. Suppose your commit history looks like this:

$ git log --pretty=oneline
Git Tag - Initial Commit

Sharing Tags

By default, the git push command does not push tags to remote servers. There is a need After creating the tag, explicitly push the tag to the shared server. This process looks like this Splitting a remote branch – you can do this:

$ git push origin <tagname>
$ git push origin v1.0
Git Tag - V1.0

If you have many tags to push at once, you can also use the –tags option of the git push command. This pushes all tags to remote servers that do not already exist.

$ git push origin --tags

Now, when someone else clones or pulls from your repository, they will get all your tags as well.
Check-in git hub whether our tags are pushed or not.

Git Tag - releases

Click the release link to open the list of tags on GitHub.

Deleting Tags:

You can use git tag -d <tagname> to remove tags in your local repository. For example, we can remove the above lightweight tags as follows:

$ git tag –d v0.1

Note that this does not remove the tag from any remote servers. In order to update any
remotes, you must use git push <remote>:refs/tags/<tagname>

$ git push origin :refs/tags/v1.0

Delete all tags at the time:

  • #Delete local tags.
  • git tag -d $(git tag -l)
  • #Fetch remote tags.
  • git fetch
  • #Delete remote tags.
  • x # Pushing once should be faster than multiple times
  • #Delete local tags.
  • git tag -d $(git tag -l)

Remote deletes

  • git ls-remote –tags origin | awk ‘/^(.)(\s+)(.[a-z0-9])$/ {print “:” $2}’ | xargs git push origin