#!/bin/sh git branch -r | grep 'tags/[0-9]' | sed -e 's"tags/\(.*\)"& v\1"' \ | while read branch tag; do if [ ! -r .git/refs/tags/$tag ]; then echo "tagging $tag from $branch" git tag $tag $branch fi done