Linux / 开发 / 默认 · 1月 19, 2023 0

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

内容纲要

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>
%d 博主赞过: