Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active October 17, 2024 20:03
Show Gist options
  • Save rponte/fdc0724dd984088606b0 to your computer and use it in GitHub Desktop.
Save rponte/fdc0724dd984088606b0 to your computer and use it in GitHub Desktop.
Getting latest tag on git repository
# 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
@arderyp
Copy link

arderyp commented Jul 18, 2023

@eggbean I like that idea, but it hits an auth wall for private/enterprise repos

@eggbean
Copy link

eggbean commented Jul 18, 2023

@arderyp There are a few different ways to authenticate. Have you tried the gh cli tool?

@Gabomfim
Copy link

Gabomfim commented Dec 4, 2023

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment