#! /usr/bin/env bash for dir in * ; do dir=${dir%*/} if [ -d "${dir}" ]; then echo "${dir}" cd "${dir}" latest_commit_with_tag=`git rev-list --tags --max-count=1` latest_tag=`git describe --tags ${latest_commit_with_tag}` git checkout "${latest_tag}" cd .. fi done