Home > php教程 > PHP开发 > Detailed explanation of tags in Git tutorial

Detailed explanation of tags in Git tutorial

黄舟
Release: 2016-12-16 15:09:26
Original
1310 people have browsed it

Git Tags

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

For example, we want to release a "1.0" version for our w3cschoolcc project. We can use git tag -a v1.0 The command tags the latest commit (HEAD) with "v1.0". The

-a option means "create an annotated label". It can be executed without the -a option, but it will not record when the tag was added or who added it, nor will it allow you to add a comment about the tag. I recommend always creating annotated tags.

$ git tag -a v1.0

When you execute the git tag -a command, Git will open your editor and let you write a tag comment, just like you write a comment for a commit.
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 新增加一行
|/ 
* 556f0a0 removed test2.txt
* 2e082b7 add test2.txt
* 048598f add test.txt
* 85fc7e7 test comment from w3cschool.cc
Copy after login

If we forget to tag a commit and publish it again, we can append tags to it.

For example, suppose we published commit 85fc7e7 (the last line in the example above), but forgot to tag it at that time. We can also now:

$ git tag -a v0.9 85fc7e7
$ git log --oneline --decorate --graph
*  88afe0e (HEAD, tag: v1.0, master) Merge branch 'change_site'
|\ 
| * d7e7346 (change_site) changed the site
* | 14b4dca 新增加一行
|/ 
* 556f0a0 removed test2.txt
* 2e082b7 add test2.txt
* 048598f add test.txt
* 85fc7e7 (tag: v0.9) test comment from w3cschool.cc
Copy after login

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

$ git tag
v0.9
v1.0

Specify tag information command:

git tag -a -m "w3cschool.cc tag"

PGP signature tag command:

git tag -s -m "w3cschool.cc tag"

The above is the detailed explanation of tags in the Git tutorial. For more related articles, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template