Skip to content

svn2git

holzkohlengrill edited this page Dec 15, 2023 · 2 revisions

SVN to git converter

#!/bin/bash
# please install git-svn
input_svn="url/to/svn/like/for/checkout"
output_git="url/to/git/like/for/cloning"

svn co "$input_svn" _svn

cd _svn
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

cat authors-transform.txt

if [[ -f "../authors-transform.txt" ]]; then
    cp "../authors-transform.txt" .
else
    echo "please change authors-transform.txt to authorSVNName = first last <email>"
    read
fi

git svn clone "$input_svn" --no-metadata -A authors-transform.txt ../_git

cd ../_git

git remote add origin "$output_git"
git push -u origin master
Clone this wiki locally