Git Checkout Latest Tag Git Checkout Latest Tag git git

Git Checkout Latest Tag


# Get new tags from remotegit fetch --tags# Get latest tag namelatestTag=$(git describe --tags `git rev-list --tags --max-count=1`)# Checkout latest taggit checkout $latestTag


git describe --tags should give you info.

bash/ shell script:

#!/bin/bash...latesttag=$(git describe --tags)echo checking out ${latesttag}git checkout ${latesttag}


In some repositories the git describe --tags gives no info and a simple git tag | tail -1 can get you the wrong tag as git sorts tags in a strange way.

For me the best command is a variation of the tail one

VERSION=$(git tag | sort -V | tail -1)