ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

Git | tag相关命令

2026/9/17 0:31:58 拓冰建站 浏览量
Git | tag相关命令

语法命令

git tag -h
usage: git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]<tagname> [<head>]or: git tag -d <tagname>...or: git tag -l [-n[<num>]] [--contains <commit>] [--no-contains <commit>] [--points-at <object>][--format=<format>] [--merged <commit>] [--no-merged <commit>] [<pattern>...]or: git tag -v [--format=<format>] <tagname>...-l, --list            list tag names-n[<n>]               print <n> lines of each tag message-d, --delete          delete tags-v, --verify          verify tagsTag creation options-a, --annotate        annotated tag, needs a message-m, --message <message>tag message-F, --file <file>     read message from file-e, --edit            force edit of tag message-s, --sign            annotated and GPG-signed tag--cleanup <mode>      how to strip spaces and #comments from message-u, --local-user <key-id>use another key to sign the tag-f, --force           replace the tag if exists--create-reflog       create a reflogTag listing options--column[=<style>]    show tag list in columns--contains <commit>   print only tags that contain the commit--no-contains <commit>print only tags that don't contain the commit--merged <commit>     print only tags that are merged--no-merged <commit>  print only tags that are not merged--sort <key>          field name to sort on--points-at <object>  print only tags of the object--format <format>     format to use for the output--color[=<when>]      respect format colors-i, --ignore-case     sorting and filtering are case insensitive

常用命令

创建tag

  1. 创建本地tag
git tag -a <tag_name> <commit_id>
  1. 推送tag到远程
git push --tags origin <remote_branch_name>

删除tag

  1. 删除本地tag
git tag -d <tag_name>
  1. 远程进行删除tag
git push origin :refs/tags/<tag_name>