Svn2Git migration


#!/bin/bash

# This script works for svn repos without branches and tags. Additional steps required to migrate branches too.
# all directories under <svn-repo-uri> (e.g.https://<svn-host>/svn/repos) will be migrated to a separate git repo:
REPOS=$(svn ls <svn-repo-uri>)

for repo in $(echo $REPOS | sed -e 's/\//\n/g')
do
git svn clone --no-metadata --authors-file=users.txt <svn-repo-uri>/"${repo}" "${repo}"-tmp.git
git clone "${repo}"-tmp.git "${repo}".git
rm -rf "${repo}"-tmp.git
cd "${repo}".git
git remote rm origin
# : e.g. git@<git-host>:<git-repo-path>
git remote add origin git@<git-host>:<git-repo-path>/"${repo}".git
git push origin master
git branch --set-upstream-to=origin/master master
cd ..
rm -rf "${repo}".git
done

Leave a Reply

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