Git tutorials in the tag details _ tips

Source: Internet
Author: User
Tags commit tagname

Git tags

If you reach an important stage and want to always remember that particular commit snapshot, you can tag it with git tag.

For example, we want to release a "1.0" version of our W3CSCHOOLCC project. We can use git tag-a v1.0 command to label the last commit (head) "v1.0".

The-a option means "create a label with annotations." It can be done without the-a option, but it will not record when the tag was played, who hit it, and would not let you add a label annotation. I recommend that you always create labels with annotations.

$ git tag-a v1.0

When you execute the git tag-a command, Git opens your editor and lets you write a tag annotation, just as you would for submitting a note.
Now, notice that when we execute git log--decorate, we can see our tags:

$ git log--oneline--decorate--graph
*  88afe0e (head, tag:v1.0, master) Merge branch ' change_site '
|\ 
| * D7E7346 (Change_site) changed the site
* | 14B4DCA new Add line
|/ 
* 556f0a0 removed test2.txt
* 2e082b7 add Test2.txt
* 048598f add test.txt
* 85fc7e7 test comment from w3cschool.cc

If we forget to label a submission and publish it again, we can tag it.

For example, suppose we publish the submission 85fc7e7 (the last line of the example above), but forgot to label it at the time. We can now also:

$ git tag-a v0.9 85fc7e7
$ git log--oneline--decorate--graph
*  88afe0e (head, tag:v1.0, master) Merge Bra  Nch ' change_site '
|\ 
| * d7e7346 (change_site) changed the site
* | 14B4DCA add a new line
|/ 
* 556f0a0 removed Test2.txt
* 2e082b7 add test2.txt
* 048598f add test.txt
* 85FC7E7 (tag:v0.9) test comment from W3cschool. Cc

If we want to view all tags, we can use the following command:

$ git tag
v0.9
v1.0

Specify label Information command:

Git tag-a <tagname>-M "w3cschool.cc label"

PGP Signature Label Command:

Git tag-s <tagname>-M "w3cschool.cc label"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.