Tagging in Git: A Guide to Marking Significant Versions
Learn how to use Git tags to mark specific versions of your project. This feature helps you easily identify and access important milestones in your development history.
Git - Tag Operation
Introduction
Tagging in Git allows developers to assign meaningful names to specific versions of a project. This makes it easier to access and reference those versions in the future. Let’s explore how david and tom use Git tags for their project.
Creating Tags
david can tag the current HEAD
by using the git tag
command. He provides a tag name with the -a
option and a tag message with the -m
option.
Syntax
[david@CentOS project]$ git tag -a 'Release_1_0' -m 'Tagged basic string operation code' HEAD
To tag a specific commit, you can use the COMMIT ID
instead of the HEAD
pointer.
Once the tag is created, david pushes the tag to the remote repository with the following command:
Syntax
[david@CentOS project]$ git push origin tag Release_1_0
Output
Counting objects: 1, done.
Writing objects: 100% (1/1), 183 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)
To gituser@git.server.com:project.git
* [new tag] Release_1_0 -> Release_1_0
Viewing Tags
Once the tag is pushed, tom can view all available tags by using the git tag
command with the -l
option:
Syntax
[tom@CentOS src]$ git tag -l
Release_1_0
To see more details about a specific tag, tom uses the git show
command followed by the tag name:
Syntax
[tom@CentOS src]$ git show Release_1_0
Output
tag Release_1_0
Tagger: david Cat
Date: Wed Sep 11 13:45:54 2013 +0530
Tagged basic string operation code
commit 577647211ed44fe2ae479427a0668a4f12ed71a1
Author: david Cat
Date: Wed Sep 11 10:21:20 2013 +0530
Removed executable binary
diff --git a/src/string_operations b/src/string_operations
deleted file mode 100755
index 654004b..0000000
Binary files a/src/string_operations and /dev/null differ
Deleting Tags
david can delete a tag from both the local and remote repositories. Here’s how to delete a tag from the local repository:
Syntax
[david@CentOS project]$ git tag -d Release_1_0
Deleted tag 'Release_1_0' (was 0f81ff4)
To delete the tag from the remote repository, david uses this command:
Syntax
[david@CentOS project]$ git push origin :Release_1_0
Output
To gituser@git.server.com:project.git
- [deleted] Release_1_0