Skip to content

Instantly share code, notes, and snippets.

@cetver
Last active May 4, 2020 17:05
Show Gist options
  • Save cetver/83786476cfdbf05feae18938134ac675 to your computer and use it in GitHub Desktop.
Save cetver/83786476cfdbf05feae18938134ac675 to your computer and use it in GitHub Desktop.
git checkout last tag
#!/usr/bin/env bash
set -eo pipefail
rep_url="https://github.com/nvm-sh/nvm.git"
last_tag=$(
git ls-remote --tags --quiet --exit-code --refs --sort version:refname "$rep_url" | \
tail --lines 1 | \
sed --regexp-extended 's@.+refs/tags/@@'
)
echo "$last_tag"
git fetch --tags
git checkout tags/"$last_tag"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment