深度阅读

How to List Local, Remote, and Latest Git tags on your repository

作者
作者
2023年08月22日
更新时间
17.6 分钟
阅读时间
0
阅读量

In this tutorial, you will learn how you can easily list Git tags.

List Local Git tags .

In order to list Git tags, you have to use the “git tag” command .

$ git tag

v1.0
v2.0

You can also execute “git tag” with the “-n .

$ git tag -n

list git tags with description

Optionally, you can specify a tag pattern followed by the tag pattern.

$ git tag -l <pattern>

git list tags using git tag command

List Remote Git tags .

As a consequence, you may have not fetched some tags that have been made available on your repository.

In order to list remote Git tags, you have to use the “git ls-remote” command with the “–tags” option.

$ git ls-remote --tags <remote>

Fetching Remote tags Easily .

To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options.

$ git fetch --all --tags

Fetching origin
From git-repository
   53a7dc..7a9ad7    master     -> origin/master
 * [new tag]         v1.0       -> v1.0
 * [new tag]         v1.0       -> v2.0

Now, you can list them easily using the “git tag .

$ git tag

v1.0
v2.0

Find latest Git Tag Available .

In order to find the latest Git tag on your list, you have to use the “git describe” command with the “–tags” option.

$ git describe

<latest_tag>

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。