Git实战指南----跟着haibiscuit学Git(第七篇)

笔名:  haibiscuit

博客园: https://www.cnblogs.com/haibiscuit/

Git地址: https://github.com/haibiscuit?tab=repositories  (欢迎star)

本项目地址: https://github.com/haibiscuit/StudyBook

尊重笔者的劳动成果,未经允许请不要转载

:git tag

(1) 查看标签

git tag

(2) 展示当前分支的最近的 tag

git describe --tags --abbrev=0

(3) 查看标签详细信息

git show <version-number>    //<version-number>tag_name

(4) 本地创建标签

git tag <version-number>

默认 tag 是打在最近的一次 commit 上,如果需要指定 commit 打 tag:

$ git tag -a <version-number> -m "v1.0 发布(描述)" <commit-id>

(5) 推送标签到远程仓库

首先要保证本地创建好了标签才可以推送标签到远程仓库:

git push origin <local-version-number>

一次性推送所有标签,同步到远程仓库:

git push origin --tags

(6) 删除本地标签

git tag -d <tag-name>

(7) 删除远程标签

删除远程标签需要先删除本地标签,再执行下面的命令:

git push origin :refs/tags/<tag-name>

(8) 切回到某个标签

一般上线之前都会打 tag,就是为了防止上线后出现问题,方便快速回退到上一版本。下面的命令是回到某一标签下的状态:

git checkout -b branch_name tag_name

猜你喜欢

转载自www.cnblogs.com/haibiscuit/p/11986422.html