Skip to content

Git Tags

Tags (It’s like a Snapshot!)

  • A tag is created to point to a very specific commit and doesn’t change never.
  • They’re not really snapshots, but they are as good as a snapshot-based database.
  • It’s just a pointer to a specific commit or a place in a time.
  • There are two flavors of tags    —>    Annotated & Non-Annotated

Ø Annotated Tag has a message that can be displayed with git show.

Ø Non-Annotated Tag is just a named pointer to a commit without any message.

Creating a Non-Annotated Tag

  • Here is an example of how to create & display a Non-Annotated Tag:
				
					# git tag tag1
# git tag
tag1
# vi file1.txt; git add -A; git commit -m “Tag Added”
# git show tag1
commit 8344e3d4dba1f214545fe6afce12034c04a63891 (tag: tag1)
Author: Arash Foroughi <arash@localhost.localdomain>
Date:   Thu Aug 14 15:10:32 2021 +0330
diff --git a/new_file b/new_file
new file mode 100644
index 0000000..dfc8289
--- /dev/null
+++ b/new_file
@@ -0,0 +1 @@
+new added
# git describe --tags
tag1-1-g4ff7c1b

				
			
  • Here is an example of how to creating & displaying an Annotated Tag:
				
					# git tag -a V1 -m “Version 1.0 Released”
# git tag
V1
tag1
# vi file_tag1.txt; git add -A; git commit -m “Tag1 Added”
# git show V1
tag V1
Tagger: “Arash <“arash@localhost”>
Version 1.0 Released
commit 4ff7c1b2422d8166d4fb376bb48e1279f08bc999 (tag: V1)
Author: “Arash <“arash@localhost”>
   Tag1 Added
diff --git a/file1.txt b/file1.txt
index 0000000..cd08755
--- /dev/null
+++ b/file1.txt
@@ -0,0 +1 @@

				
			

Leave a Reply

Your email address will not be published. Required fields are marked *