Git enterprise development control theory and practice - from entry to in-depth (5)|Tag management

foreword

Well, the blogger here will first post some columns full of dry goods!

The first is a summary of bloggers’ high-quality blogs. The blogs in this column are all the bloggers’ most thoughtful writing. They are full of dry goods. I hope they will be helpful to everyone.

Then there is a column "Git Enterprise Development Control Theory and Practical Operations" that the blogger spends the most time recently. I hope everyone will pay more attention!


Git tag management

understand tags

The label tag can be simply understood as an identification of a certain commit, which is equivalent to an alias. For example, when a certain version of the project is released, a label like v1.0 is used for the last commit to identify the significance of the milestone.

What's the use of this? Compared with the hard-to-remember commit id, tag solves this problem very well, because the tag must be given an easy-to-remember and meaningful name. When we need to roll back to an important version, we can quickly locate it by directly using tags.

Action tab

First switch to the branch to be tagged. Then hit the label.

git tag v1.0 # 给最新的这一次提交打上标签名为"v1.0"
git tag # 查看当前有哪些标签存在

It can be proved that the labeling is for the latest submission.

├── ORIG_HEAD
├── packed-refs
└── refs
    ├── heads
    │   └── master
    ├── remotes
    │   └── origin
    │       ├── HEAD
    │       └── master
    └── tags
        └── v1.0

24 directories, 38 files
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ cat .git/refs/tags/v1.0 
7393ea000a2f7baae095b045b0bcd946718d404d
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git log
commit 7393ea000a2f7baae095b045b0bcd946718d404d
Author: Yufch <[email protected]>
Date:   Thu Aug 24 23:48:08 2023 +0800

You can see that the one stored in the tag is the latest one commit id.

commitIt is also possible to label the previous ones , commit idjust follow up.

git tag v0.9 xxxx # 后面跟上commit id就行了

Of course, tagyou can also keep up with the description later.

git tag -a v0.8 -m "important tag:XXX" xxxx # 后面跟上commit id即可

Then how to check this description?

git show v0.8 # 查看v0.8这个标签的详细信息
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git lpa
7393ea0 add .gitignore
8513266 update file.txt.
7352d02 create file.txt
a9af182 Initial commit
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git tag -a v0.8 -m "important tag:XXX" a9af182
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git tag
v0.8
v1.0
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git show v0.8
tag v0.8
Tagger: Yufch <[email protected]>
Date:   Fri Aug 25 17:02:54 2023 +0800

important tag:XXX

commit a9af182743c539e1ed0ba46cf847580e542473ed
...

push label

git push origin v1.0 # 把tag: v1.0 推送到远程
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git push origin v1.0
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To [email protected]:Yufch/remote-gitcode.git
 * [new tag]         v1.0 -> v1.0

insert image description here
insert image description here

has been pushed to the remote.

Of course, you can also push all tags at once.

git push origin --tags # 推送本地所有标签到远程
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ git push origin --tags
Counting objects: 1, done.
Writing objects: 100% (1/1), 162 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To [email protected]:Yufch/remote-gitcode.git
 * [new tag]         v0.8 -> v0.8
(base) [yufc@ALiCentos7:~/Src/Bit-Courses/GitDevelopment/remote-gitcode]$ 

delete label

git tag -d v1.0 # 删除本地的v1.0标签

pushThen I said that the remote cannot be operated directly, but we can delete the remote tags locally and through the method.

git push origin :v1.0

Guess you like

Origin blog.csdn.net/Yu_Cblog/article/details/132527578