Difference: 1. Tag is a point in a series of commits, which can only be viewed and cannot be moved; while branch is a series of commit lines in series and can be extended. 2. Tag is static, branch is dynamic and needs to move forward.
The operating environment of this tutorial: Windows 7 system, Git version 2.30.0, Dell G3 computer.
The difference between tag and branch
Git tag is a point in a series of commits. It can only be viewed and cannot be moved. A branch is a series of commit lines connected in series.
tag is static, branch is dynamic and needs to move forward.
Usage of git tag
- We often use git to create a tag when sealing the code, like this The unmodifiable historical code version is as if it has been sealed by us. Whether it is operation and maintenance release pull, or future code version management, it is very convenient
git's tag function
There are actually two situations when tagging under git
- Lightweight: It is actually an independent branch, or an immutable one Branch. A reference to a specific commit object
With annotation: It is actually an independent object stored in the warehouse. It has its own checksum information, including the name of the tag and the tag description. , the tag itself also allows the use of GNU Privacy Guard (GPG) to sign or verify, email address and date. Generally, we recommend using tags with comments to retain relevant information
So we recommend using the second tag form
Create tag
View tag
- git tagTo display the annotation information, we need to use the show command to view
- git show V1.2But currently this tag is only submitted to the local git repository. How to synchronize to the remote code repository
- git push origin --tagsIf you just synchronized it, you A fatal bug was discovered and the version needs to be re-released. It is not too late.
- git tag -d V1.2At this point we just deleted it The local V1.2 version, but the online V1.2 version still exists, what should I do? At this time, we can push the empty version of the same name offline to achieve the goal of deleting the online version:
- git push origin :refs/tags/V1.2How to get the remote version?
- git fetch origin tag V1.2In this way we can accurately pull a specified version. It is suitable for operation and maintenance students to deploy the specified version.
Recommended learning: "
Git Tutorial"
The above is the detailed content of What is the difference between git tag and branch?. For more information, please follow other related articles on the PHP Chinese website!
Statement: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