Continue SVN history in a git repository

The following is a basic command to continue (part of) a Subversion repository as a git repository.

git svn clone -A authors --no-metadata --localtime $URL

The file authors can be initially empty. The process will be interrupted when an unknown author is encountered. The format is:

username = Firstname Lastname <email>

Alternatively, if you want to recover the author information from Unix user accounts:

git filter-branch --env-filter ". ~/filter.sh" HEAD

Where filter.sh is something like:

mail="$(cat /etc/mailname)"
 
user="$GIT_AUTHOR_NAME"
full="$(getent passwd "$user" | cut -d ':' -f 5 | cut -d ',' -f 1)"
if [ -n "$full" ]; then
        GIT_AUTHOR_NAME="$full"
        GIT_AUTHOR_EMAIL="$user@$mail"
fi
 
user="$GIT_COMMITTER_NAME"
full="$(getent passwd "$user" | cut -d ':' -f 5 | cut -d ',' -f 1)"
if [ -n "$full" ]; then
        GIT_COMMITTER_NAME="$full"
        GIT_COMMITTER_EMAIL="$user@$mail"
fi

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>