Skip to content

Instantly share code, notes, and snippets.

@JrCs
Created August 17, 2012 23:59
Show Gist options
  • Save JrCs/3383535 to your computer and use it in GitHub Desktop.
Save JrCs/3383535 to your computer and use it in GitHub Desktop.
Script to help to clone annotated tags
#!/bin/bash
# This script clone a tag and add a v prefix to it
# All the tags are commit with the same author/email
set -u
# To force author and email we need to change the local configuration
git config user.name kapeka
git config user.email kapeka@users.sourceforge.net
git tag -l | grep '^4\.' | while read tag;do
echo $tag
commit=$(git cat-file tag $tag | sed -n 's/^object *\(.*\)$/\1/p')
tagger_date=$(git cat-file tag $tag | egrep '^tagger .*<.+> [0-9]'| sed 's/^.*> *//')
git cat-file tag $tag | sed '1,/^ *$/d' > tag-message
GIT_COMMITTER_DATE=$tagger_date git tag -f -a -F tag-message "v$tag" $commit
done
rm -f tag-message
git config --remove-section user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment