Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use tag tags in Git

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about how to use tag tags in Git, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

What is tag

Tag is a tag for the git version library, a pointer to a commit.

Tag is mainly used for the management of release versions. After a version is released, we can add v.1.0.1 v.1.0.2 to git. A label like this.

Tag feels a little similar to branch, but it is essentially different from the division of labor:

Tag corresponds to a certain commit, which is a point and is immovable.

Branch corresponds to a series of commit, which is a line connected by many dots. There is a HEAD pointer that can be moved by the HEAD pointer.

Therefore, the difference between the two determines the way to use, change the code with branch, do not change only view with tag.

The mutual use of tag and branch sometimes has a very convenient effect. For example, three versions of v1.0 v2.0 v3.0 have been released. At this time, I suddenly want to add a new function on the basis of v2.0 as v4.0 without changing the existing code. You can check out the v2.0 code as a branch and then as a development branch.

Second, the simple use of tag 1. Create a tag:

The creation of tag is based on the commit of the local branch, and it is different from the push of the branch, that is, the branch has been pushed to the remote, but your tag does not. If you push the tag to the remote branch, you need to execute the tag push command.

Git tag / / create a local tag

Git push origin / / push to remote warehouse

If there are a lot of unpushed local tags, you want to push them all at once:

Git push origin-tags

The above is a tag created based on the last commit of the local current branch, but if you don't want to use the last one, you just want to tag a specific submission, as long as you know the id of the commit.

Git log-- pretty=oneline / / View the submission history of the current branch including commit id

Git tag-a

two。 View label

View the details of a local tag:

Git show

View all local tag:

Git tag or git tag-l

View all remote tag:

Git ls-remote-tags origin

3. Delete label

Deletion of local tag:

Git tag-d

Deletion of remote tag:

Git push origin:

4. Check out label

Git checkout-b

Because tag itself points to a commit, it is the same as checking out branches based on commit id.

But it is important to note that if we want to modify the tag checkout code branch, the commit of the tag tag remains the same, although the code in the branch has changed, and the tag code will not change.

Other

Command git tag-a-m "XXX..." You can specify label information.

The command git tag-a v0.1.0-m "release 0.1.0 version" creates a note tag.

The command git checkout [tagname] toggles the label.

The above is how to use the tag tag in Git. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report