Git Commands : Tags

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Topic : Tags :  Reference : https://git-scm.com/book/en/v2/Git-Basics-Tagging

>>> Listing Your Tags

$ git tag
v1.0
v2.0

>>> You can also search for tags that match a particular pattern. The Git source repo, for instance, contains more than 500 tags. If you’re interested only in looking at the 1.8.5 series, you can run this: 

$ git tag -l "v1.8.5*"
v1.8.5
v1.8.5-rc0
v1.8.5-rc1
v1.8.5-rc2
v1.8.5-rc3
v1.8.5.1
v1.8.5.2
v1.8.5.3
v1.8.5.4
v1.8.5.5

>>> Creating Tags

Git supports two types of tags: lightweight and annotated.

A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

Annotated Tags

Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the tag command:

$ git tag -a v1.4 -m "my version 1.4"
$ git tag
v0.1
v1.3
v1.4

The -m specifies a tagging message, which is stored with the tag. If you don’t specify a message for an annotated tag, Git launches your editor so you can type it in.

- a stands for annotated

 

 

>>> You can verify that your Git tag was successfully created by running the “git tag” command with the “-n” option.

$ git tag -n 

ver_1.0         Adding Tag

 

 

>>> You can see the tag data along with the commit that was tagged by using the git show command:

$ git show ver_1.0

tag ver_1.0
Tagger: sreejith <sreejith.sbk@gmail.com>
Date:   Wed May 18 11:07:34 2022 +0530

Adding Tag

commit 193cdb45ef7d08a3e5f8c712258453780c75589a (tag: ver_1.0)
Author: sreejith <sreejith.sbk@gmail.com>
Date:   Wed May 18 11:05:36 2022 +0530

    Commented Variable undone

diff --git a/main.tf b/main.tf
index 13eb5cc..bd940d3 100644
--- a/main.tf
+++ b/main.tf
@@ -115,11 +115,4 @@ resource "oci_sch_service_connector" "test_service_connector" {

 }

-data "oci_sch_service_connector" "test_service_connector" {
-  service_connector_id = oci_sch_service_connector.test_service_connector.id


>>> Lightweight Tags

Another way to tag commits is with a lightweight tag. This is basically the commit checksum stored in a file — no other information is kept. To create a lightweight tag, don’t supply any of the -a, -s, or -m options, just provide a tag name:

$ git tag v1.4-lw

$ git tag
v0.1
v1.3
v1.4
v1.4-lw
v1.5


>>> For Lightweight Tags : This time, if you run git show on the tag, you don’t see the extra tag information. The command just shows the commit:

$ git show v1.4-lw
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date:   Mon Mar 17 21:52:11 2008 -0700

    Change version number


>>> Tagging Later

You can also tag commits after you’ve moved past them. Suppose your commit history looks like this:

$ git log --pretty=oneline
15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
a6b4c97498bd301d84096da251c98a07c7723e65 Create write support
0d52aaab4479697da7686c15f77a3d64d9165190 One more thing
6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'
0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc Add commit function
4682c3261057305bdd616e23b64b0857d832627b Add todo file
166ae0c4d3f420721acbb115cc33848dfcc2121a Create write support
9fceb02d0ae598e95dc970b74767f19372d61af8 Update rakefile
964f16d36dfccde844893cac5b347e7b3d44abbc Commit the todo
8a5cbc430f1a9c3d00faaeffd07798508422908a Update readme

Now, suppose you forgot to tag the project at v1.2, which was at the “Update rakefile” commit. You can add it after the fact. To tag that commit, you specify the commit checksum (or part of it) at the end of the command:

$ git tag -a v1.2 9fceb02





Comments

Popular posts from this blog

GitHub : Troubleshooting

GIT - Company