Now that you know How to automatically tag a Git repository an interesting command to know about is “How to automatically checkout the latest tag of a Git repository”. Let’s imagine that you want to automatically release a stable version of your product (that have dependencies or not) based on the latest version available on your repository.
An easy way to do it is to follow the following steps:
# Get new tags from the remote
$ git fetch --tags
# Get the latest tag name
$ latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
# Checkout the latest tag
$ git checkout $latestTag