#!/bin/sh git branch -r | egrep 'tags/(|PR)[0-9]' | sed -e 's"tags/\(.*\)"& v\1"' \ | while read branch tag; do if ! git show-ref -q "$tag"; then echo "Tagging $tag from $branch" git tag $tag $branch elif [ `git show-ref -s $branch` != `git show-ref -s $tag` ]; then echo "Updating $tag from $branch" git tag -f $tag $branch fi done