Skip to content

Instantly share code, notes, and snippets.

@MedUnes
Last active June 12, 2022 20:47
Show Gist options
  • Save MedUnes/706380225fdb0ce79a13378d5b1af695 to your computer and use it in GitHub Desktop.
Save MedUnes/706380225fdb0ce79a13378d5b1af695 to your computer and use it in GitHub Desktop.
[Bash] Get the n(th) git tag
#!/bin/bash
n=$1
git for-each-ref --sort=-taggerdate | grep refs/tags/v | cut -d '/' -f 3 | head -$n | tail -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment