Git の annotated tag を lightweight tag に変換する

grep 'refs/tags/.*\^{}$' .git/info/refs | while read line; do
  hash=${line:0:40}
  tag=${line##*/}
  tag=${tag%^*}
  git tag -d $tag
  git tag $tag $hash
  git push origin :$tag
done
git push --tags

clone 済みのリポジトリでは

git fetch --tags

経緯

古いリポジトリの tag を 1.0 から v1.0 形式に変更したところ

$ git describe
warning: tag '1.0' is really 'v1.0' here
1.0-123-g0123456

みたいな警告がでた。

annotated と lightweight が混在している上に、 大したコメントが付いているわけでもないため、 煩わしいので削除した。