banner



How To Run A Tag # To See Who It Is Registered To

Git Tag Explained: How to List, Create, Remove, and Show Tags in Git

Tagging lets developers mark important checkpoints in the course of their projects' development. For instance, software release versions tin can exist tagged. (Ex: v1.3.2) It substantially allows you lot to give a commit a special proper name(tag).

To view all the created tags in alphabetical order:

                git tag              

To get more information on a tag:

                git show v1.4              

In that location are two types of tags:

Annotated

                git tag -a v1.2 -one thousand "my version i.four"              

Lightweight

                git tag v1.2              

They differ in the manner that they are stored.
These create tags on your current commit.

Incase, yous'd like to tag a previous commit specify the commit ID y'all'd like to tag:

                git tag -a v1.ii 9fceb02              

The tags names may exist used instead of commit IDs while checking out and pushing commits to a remote repo.

More Information:

  • Git documentation: Documentation
  • Git Tagging Chapter: Book

You can listing all available tags in a project with the git tag control (nate that they will appear in alphabetical order):

                $ git tag v1.0 v2.0 v3.0              

This way of listing tags is peachy for pocket-size projects, but greater projects can have hundreds of tags, so you may need to filter them when searching for an important point in the history. You can observe tags containing specific characters calculation an -l to the git tag command:

                $ git tag -l "v2.0*" v2.0.1 v2.0.2 v2.0.3 v2.0.4              

Create a tag

You can create two type of tags: annotated and lightweight. They commencement ones are compete objects in GIT database: they are checksummed, requiere a message (like commits) and store other important data such as name, electronic mail and date. On the other hand, lightweight tags don crave a mesage or shop other data, working but every bit a pointer to a specific point in the project.

Create an annotated tag

To create an anotated tag, add -a tagname -m "tag bulletin" to the git tag command:

                $ git tag -a v4.0 -grand "release version 4.0" $ git tag v1.0 v2.0 v3.0 v4.0              

As you can meet, the -a specifies that you lot are creating an annotated tag, after comes the tag name and finally, the -1000 followed by the tag message to shop in the Git database.

Create a lightweight tag

Lightweight tags contain only the commit checksum (no other information is stored). To create one, simply run the git tag command without any other options (the -lw characters at the cease of the name are used to betoken lightweight tags, but yous tin can mark them every bit you similar):

                $ git tag v4.i-lw $ git tag v1.0 v2.0 v3.0 v4.0 v4.1-lw              

This time you didn't specify a message or other relevant data, so the tag contains simply the refered commit'due south checksum.

View tag'due south data

You can run the git show control to view the data stored in a tag. In the case of annotated tags, you'll meet the tag data and the commit information:

                $ git evidence v4.0 tag v4.0 Tagger: John Cash <john@greenbacks.com> Date:   Monday Sabbatum 28 15:00:25 2017 -0700  release version iv.0  commit da43a5fss745av88d47839247990022a98419093 Author: John Cash <john@cash.com> Appointment:   Fri Feb 20 20:xxx:05 2015 -0700    finished details              

If the tag you are watching is a lightweight tag, y'all'll but see the refered commit data:

                $ git show v1.4-lw commit da43a5f7389adcb9201ab0a289c389ed022a910b Author: John Cash <john@greenbacks.com> Date:   Fri Feb 20 20:30:05 2015 -0700    finished details              

Tagging sometime commits

You can too tag past commits using the git tag commit. In order to do this, you'll demand to specify the commit's checksum (or at to the lowest degree a part of it) in the command'south line.

First, run git log to discover out the required commit's checksum:

                $ git log --pretty=oneline ac2998acf289102dba00823821bee04276aad9ca added products section d09034bdea0097726fd8383c0393faa0072829a7 refactorization a029ac120245ab012bed1ca771349eb9cca01c0b modified styles da43a5f7389adcb9201ab0a289c389ed022a910b finished details 0adb03ca013901c1e02174924486a08cea9293a2 small fix in search textarea styles              

When yous have the checksum needed, add together it at the terminate of the tag creation line:

                $ git tag -a v3.5 a029ac              

You'll see the tag was correctly added running git tag:

                $ git tag v1.0 v2.0 v3.0 v3.5 v4.0 v4.1-lw              

Git does't button tags past default when you run the git push command. And so, to succesfully push a tag to a server you lot'll take to git push origin command:

                $ git button origin v4.0 Counting objects: 14, done. Delta compression using up to 8 threads. Compressing objects: 100% (16/sixteen), done. Writing objects: 100% (18/18), 3.fifteen KiB | 0 bytes/s, done. Total 18 (delta 4), reused 0 (delta 0) To git@github.com:jcash/gitmanual.git  * [new tag]         v4.0 -> v4.0              

You can also employ the --tags option to add together multiple tags at once with the git push button origin command:

                $ git push origin --tags Counting objects: 1, washed. Writing objects: 100% (one/i), 160 bytes | 0 bytes/s, done. Total ane (delta 0), reused 0 (delta 0) To git@github.com:jcash/gitmanual.git  * [new tag]         v4.0 -> v4.0  * [new tag]         v4.1-lw -> v4.1-lw              

You lot can apply git checkout to checkout to a tag like yous would normally exercise. But you need to keep in mind that this would outcome a detached Caput land.

                $ git checkout v0.0.3 Note: checking out 'v0.0.iii'.  You lot are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits yous make in this land without impacting any branches by performing another checkout.              

Deleting a Tag

Y'all may find a situation were you lot want to delete a certain tag. There's a very useful command for this situations:

                $ git tag --delete v0.0.2 $ git tag v0.0.i v0.0.3 v0.0.4              

More Information

  • Git Pro - Tagging Basics
  • Git Pro - Documentation
  • Git HowTo
  • Git tip: Tags
  • Creating a tag

Sources

Git documentation: tags


Acquire to code for gratis. freeCodeCamp'due south open source curriculum has helped more than 40,000 people get jobs as developers. Go started

Source: https://www.freecodecamp.org/news/git-tag-explained-how-to-add-remove/

Posted by: steinvoiled.blogspot.com

0 Response to "How To Run A Tag # To See Who It Is Registered To"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel