Skip to content

Instantly share code, notes, and snippets.

@Constaline
Forked from rponte/get-latest-tag-on-git.sh
Created October 19, 2021 09:17
Show Gist options
  • Select an option

  • Save Constaline/03b37fb6c761afba6af1e5cdd3f24af2 to your computer and use it in GitHub Desktop.

Select an option

Save Constaline/03b37fb6c761afba6af1e5cdd3f24af2 to your computer and use it in GitHub Desktop.

Revisions

  1. @rponte rponte revised this gist Sep 10, 2015. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions get-latest-tag-on-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    [email protected]

    # The command finds the most recent tag that is reachable from a commit.
    # If the tag points to the commit, then only the tag is shown.
    # Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
  2. @rponte rponte revised this gist Sep 10, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion get-latest-tag-on-git.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,6 @@ [email protected]
    # If the tag points to the commit, then only the tag is shown.
    # Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
    # and the abbreviated object name of the most recent commit.

    git describe

    # With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
  3. @rponte rponte created this gist Sep 10, 2015.
    17 changes: 17 additions & 0 deletions get-latest-tag-on-git.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    [email protected]

    # The command finds the most recent tag that is reachable from a commit.
    # If the tag points to the commit, then only the tag is shown.
    # Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
    # and the abbreviated object name of the most recent commit.

    git describe

    # With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
    git describe --abbrev=0

    # other examples
    git describe --abbrev=0 --tags # gets tag from current branch
    git describe --tags `git rev-list --tags --max-count=1` # gets tags across all branches, not just the current branch