Git Learning (vii) TAG management

Source: Internet
Author: User
Tags git commands

Git Learning (vii) TAG management

  

When you publish a version, you usually start with a tag in the repository, so that the only version that determines the time to tag is the one. Taking out a version of a tag is to take the historical version of that tag moment. Therefore, the tag is also a snapshot of the repository.

Git's tag is a snapshot of the repository, but it is a pointer to a commit (similar to a branch, but the branch can be moved, the label is not), and creating and deleting tags is instantaneous.

This article explains how to create labels and manipulate tags in Git.

  

Create a label

The commands for the git tag are simple, so let's start by looking at the git commands below:

git tag View Tags

git tag < tag name> <commit id> create < Span style= "color: #ff00ff;" > tag, if no commit ID default current

git tag-a < tag name>-M <msg>    create < Span style= "color: #ff00ff;" > label, and add tag information

Git show< tag name ; View label Details

Can do some simple practice, did not create a tag directly with git tag display as empty;

Create a v1.0 label on the master branch, and then view it as follows

It's so easy to tag


The default tag is on the most recently committed commit (the current branch snapshot). Sometimes, if you forget to hit the tag, you need to find the commit ID of the history submission and then hit it.

We have to operate under the other branches to tag, switch to the dev branch (if none, can create a new branch), if the development of v1.1 version under the branch, you must hit v1.1 tag, you can manipulate git tag v1.1

Check the label again to see that there are currently two tabs

Switch to the master branch, see again, there are also two tags, the tag is recorded in the entire Git library, the branch does not affect.

We commit two times on the master branch and play the current branch as V2.0, there are currently three tabs

However, now, suddenly think of the previous commit need to hit the v1.2 label, you have to hit the label, then how to operate it? Knowing the commit ID of the previous commit, git log is as follows

Learn Commitid, take the top 7 can ffe7d78

Note that labels are not listed in chronological order, but are sorted alphabetically. (v2.0 tag is before v1.2)

Note that the label cannot be repeatedly hit, if it already exists, will prompt, but allow the same commit ID to hit multiple tags

View the label content, such as git show v1.1 , as shown below, to know the tag's commit ID and the difference from the current version

When you create a label, you can add a comment message that is

Can be used to indicate the use of PGP signature label, must first install GPG (GnuPG), if not found GPG, or no GPG key pair, will be error; Please search your own research for the signature method.

git tag-s < tag name>-M <msg>    create signature < Span style= "color: #ff00ff;" > label, and add tag information

Delete a label

If the label is wrong, it can be deleted directly, the command is as follows:

Git tag-d < tag name>-M <msg>    delete label

remove v1.2 tags  

tags created are stored locally only and are not automatically pushed to remote. Therefore, the wrong tag can be safely deleted locally. See the Remote tab below.

Remote label

As mentioned earlier, local labels are not pushed to the remote. Take a look at the remote label display, as follows GitHub, currently the library does not have any tags

If you want to push the label to remote, use the following command:

Git Push Origin < tag Name>         push a label to the remote

&NBSP;

Git push Origin--tags         push all tags to remote

The local library has three tabs, which can be pushed using a single tag, as follows:

Post-push

Push All

If the label has been pushed to the remote, it is troublesome to remove the remote label, remove it locally, and then remove it remotely. The Delete command is also push, but the format is as follows:

git push Origin : Refs/tags/<tagname>        

Git Learning (vii) TAG management

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.