Git: tag 标签操作
Git中的标签(tag)可以针对某一时间点的版本做标记,常用于版本发布。
1. 打标签
Git标签分为两种类型:轻量标签和带注释的标签。轻量标签是指向提交对象的引用,带注释的标签则是仓库中的一个独立对象。建议使用带注释的标签。
轻量标签:
$ git tag v1.3.2
带注释的标签:
$ git tag -a v1.3.3 -m “The 1.3.3 version”
创建轻量标签不需要传递参数,直接指定标签名称即可。创建附注标签时,参数a即annotated的缩写,指定标签类型,后附标签名。参数m指定标签说明,说明信息会保存在标签对象中。
2. 列出本地所有标签
$ git tag v1.3.1 v1.3.2 v1.3.3
3. 查看标签信息
$ git show v1.3.3
4. 搜索标签
$ git tag -l "v1.3.*" v1.3.1 v1.3.2 v1.3.3
其中的“l”就是 list的意思,比如上面会搜索出v1.3.x的版本tag
5. 切换到指定标签的版本
$ git checkout -b test_version v1.3.2 Switched to a new branch 'test_version'
其中的“test_version”就是新切换的分支的名字,v1.3.2 就是之前v1.3.2版本打的tag名字。
PS: 也可以直接使用 git checkout v1.3.2 , 但这样会使当前的分支处于游离态(‘detached HEAD’ state), 如果你需要对旧版本进行修改,最好像上面一样创建一个新的分支。
6. 给历史提交打标签
$ git log --oneline c39f9f1 (HEAD -> feature/like_samsung_ui_3, tag: v1.3.3) android:Refactor: update the jump logic of the device select interface 515a718 android:Feature: Display device type icon according to device type 77c01e5 (tag: v1.3.2, test_version) android:Feature: Add engineering mode d2f1956 (tag: v1.3.1) android:Bugfix: Fixed the problem that the headset mode cannot be switched by double-clicking the MFB button 0562f99 android:Feature: Add some code for create & destroy SCO link e02f711 android:Feature: establish an A2DP link while connecting the device 5e2d67d android:Feature: modify the name of eq (eq0, eq1, eq2) to the corresponding actual effect name 01c0ad0 android:Feature: Supports orderly sending of multiple command 9286c66 android:BugFix: Fixed the problem that RadioGroup#onCheckedChanged() was called multiple times 5be1cb7 android:BugFix: Fixed the problem that get audio eq index failed a290b93 android:Feature: add new command: CMD_HA_APT_EQ_INDEX_SET, CMD_HA_APT_EQ_INDEX_GET bad0659 android:Feature: add command CMD_HA_GET_APT_VOL_LEVEL & CMD_HA_SET_APT_VOL_LEVEL 92e6a89 android:Refactor: use DSP-APT EQ parameter settings 5026f7a (feature/like_samsung_ui_2) android:BugFix: Fixed the response timeout issue on OPPO reno CPH1917 52a586b android:Feature: add eq mode settings implementation edc409b android:Feature: add LLAPT command implementation $ git tag -a v1.3.0 -m "The 1.3.0 version" 0562f99 $ git log --oneline c39f9f1 (HEAD -> feature/like_samsung_ui_3, tag: v1.3.3) android:Refactor: update the jump logic of the device select interface 515a718 android:Feature: Display device type icon according to device type 77c01e5 (tag: v1.3.2, test_version) android:Feature: Add engineering mode d2f1956 (tag: v1.3.1) android:Bugfix: Fixed the problem that the headset mode cannot be switched by double-clicking the MFB button 0562f99 (tag: v1.3.0) android:Feature: Add some code for create & destroy SCO link e02f711 android:Feature: establish an A2DP link while connecting the device 5e2d67d android:Feature: modify the name of eq (eq0, eq1, eq2) to the corresponding actual effect name 01c0ad0 android:Feature: Supports orderly sending of multiple command 9286c66 android:BugFix: Fixed the problem that RadioGroup#onCheckedChanged() was called multiple times 5be1cb7 android:BugFix: Fixed the problem that get audio eq index failed a290b93 android:Feature: add new command: CMD_HA_APT_EQ_INDEX_SET, CMD_HA_APT_EQ_INDEX_GET bad0659 android:Feature: add command CMD_HA_GET_APT_VOL_LEVEL & CMD_HA_SET_APT_VOL_LEVEL 92e6a89 android:Refactor: use DSP-APT EQ parameter settings 5026f7a (feature/like_samsung_ui_2) android:BugFix: Fixed the response timeout issue on OPPO reno CPH1917 52a586b android:Feature: add eq mode settings implementation edc409b android:Feature: add LLAPT command implementation
首先用 git log --oneline 指令找出历史提交的commit id, 然后在打tag的指令末尾加上这个commit id 即可。
7. 删除标签
$ git tag -d v1.3.0 Deleted tag 'v1.3.0' (was 91cc764)
8. 推送标签到远程Git服务器
推送一条标签信息
$ git push origin v1.3.5
推送本地所有标签信息
$ git push origin –tags
参考链接:
2. Git 基础 - 打标签
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
分类:
Git-日常使用
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
2018-03-30 8.线程
2017-03-30 C语言基础(21)-C语言编译过程及GCC参数简介