git tag — tag related operations

Tags can be used to mark versions at a certain point in time, and are often used for version releases.

  • list tags

Git  tag # Print out all tags of the current repository on the console
$ git tag -l 'v0.1.*' # Search for tags that match the pattern

  • tag

There are two types of git tags: lightweight tags and annotation tags. A lightweight tag is a reference to a commit object, and an annotated tag is a separate object in the repository. A note label is recommended.
# Create light tags
$ git tag v0.1.2-light

# Create an annotation tag
$ git tag -a v0.1.2 -m "version 0.1.2"

There is no need to pass parameters to create a lightweight tag, just specify the tag name directly.
When creating an annotated label, the parameter a is the abbreviation of annotated, specifies the label type, and appends the label name. The parameter m specifies the label description, and the description information will be saved in the label object.

  • switch to tab

The same as the switch branch command, you can view the version information of the git checkout [tagname]
tag
with git showthe command to view the tag information:
$ git show v0.1.2

  • remove tag

If you make a mistake or need to modify the label, you need to delete the label first, and then type a new label.
$ git tag -d v0.1.2 # delete tag

The parameter d is the abbreviation of delete, which means to delete the label specified after it.

  • Tag the specified commit

Tagging does not have to be on the head, it can also be tagged on previous versions, which requires you to know the checksum of a commit object (by git loggetting it).
# Make up the tag
$ git tag -a v0.1.1 9fbc3d0

  • Label release

Usually, git pushthe tag object will not be submitted to the git server, we need to do explicit operations:
$ git push origin v0.1.2 # Commit the v0.1.2 tag to the git server
$ git push origin –tags # All local tags at once commit to git server

 

Note: If you want to see the file in a previous label state, you can do this

1. git tag View the tags under the current branch

2.git checkout v0.21 will now point to the code state when the v0.21 tag was hit, (but now it is on an empty branch)

3. cat test.txt to view a file

 

Reprinted from: http://blog.csdn.net/wangjia55/article/details/8793577/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326399127&siteId=291194637