在 Git 中,tag 通常用于标记某个提交(commit)作为项目的某个重要节点,例如发布版本(v1.0、v2.0 等)。Git 支持两种类型的 tag:
bash
git tag
bash
git tag
示例:
bash
git tag v1.0-light
bash
git tag -a
示例:
bash
git tag -a v1.0 -m "Release version 1.0"
先查看提交历史获取 commit hash:
bash
git log --oneline
然后给指定 commit 打标签:
bash
git tag -a
示例:
bash
git tag -a v0.9 abc1234
默认 git push
不会推送 tag,需手动推送:
bash
git push origin
推送所有本地标签:
bash
git push origin --tags
bash
git tag -d
bash
git push origin :refs/tags/
或使用新语法(Git >= v1.8.0):
bash
git push --delete origin
bash
git show
# 创建附注标签
git tag -a v1.1 -m "正式发布1.1版本"
# 查看标签信息
git show v1.1
# 推送标签到远程仓库
git push origin v1.1
v1.0.0
、release-202406
。如有更具体场景(如从图形界面工具操作、配合 GitHub/Gitee 使用等),可继续提问。