Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. 如何使用 Git
  6. 如何在 Git 中使用标签
  7. 添加标签
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

添加标签

使用 git tag 命令添加一个名为tag1的新标签。

$ git tag tag1

然后,运行不带任何参数的 tag 命令,您将看到此存储库中的标签列表,包括我们刚刚添加的标签。

$ git tag
  tag1

要查看带有标签信息的历史日志,请执行 git log 命令--decorate选项。

$ git log --decorate
  commit e7978c94d2104e3e0e6e4a5b4a8467b1d2a2ba19 (HEAD, tag: tag1, main)
  Author: yourname <yourname@yourmail.com>
  Date:   Wed Jul 18 16:43:27 2022 +0900

      first commit

这就是我们的历史记录现在的样子。

Add a tag "tag1" to the commit indicated by the current HEAD

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life