给指定 commit 打 tag 并提交 tag
Terry
It has been 0 days since the last update of this post. Some contents may be outdated. Please pay attention to screening.

合并代码的时候总是忘了打 tag , 合并完了才发现需要补 tag。
需要给指点 commit 补上 tag 并提交

  1. 给指定 commit 打 tag
1
git tag tagName commitId
  1. 提交 tag
1
git push origin tagName
  1. 给当前分支加 tag

tag 会加在当前分支的最后一次提交上(截止打 tag 的最后一次提交哈)。

1
git tag tagName
  1. 给 tag 加注释
1
2
3
4
5
6
git tag -a tagName -m "注释"
git tag -a tagName commitId -m "注释"
没有注释,别加-a,会报错,即打 tag 失败
git tag tagName -m "注释"
git tag tagName commitId -m "注释"
git tag tagName -m "注释" commitId
  1. 删除本地 tag

tag 还没提交,只需删除本地 tag

1
2
git tag -d tagName
git tag --delete tagName
  1. 删除远程仓库的 tag
1
2
3
4
5
6
# tag 已经提交到远端
git push origin -d tagName
git push -d origin tagName
git push origin --delete tagName
git push --delete origin tagName
git push origin :refs/tags/tagName

7 tag 列表

1
2
3
4
5
6
7
# 本地所有 tag
git tag
git tag -l
git tag --list

# 匹配v1.1.x的 tag
git tag -l "v1.1.*"