migrate from svn to git (the full story)
let’s assume you have an svn repository available on some remote server. You want to migrate to git, but not lose all that yummy commit history. None of the posts I read quite managed to cover all the steps involved, so here they are:
setup the bare repo on your remote server
ssh example.com
mkdir -p /repos/my_app.git && cd /repos/my_app.git
git --bare init
exit
create a user mapping file
this temporary file will map usernames referenced in svn commit logs to new git-friendly ones. (referenced later as ~/Desktop/users.txt)
bob = Bob Zoller <bob@example.com>
carl = Carl Yestrau <carl@example.com>
phillip = Phillip Bensaid <phillip@example.com>
you might need to add strange entries for usernames like “password” or “(no author)”, so watch out for that.
use git-svn to fetch your existing svn repository
mkdir my_app_tmp
cd my_app_tmp
git-svn init svn+ssh://example.com/home/svn/my_app/trunk/ --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git-svn fetch
now wait… depending on the size of your svn repo, this can take a long time.
git-clone your tmp app
cd ..
git clone my_app_tmp my_app_clean
remove the remote branch
cd my_app_clean
git remote rm origin
add your new remote branch
git remote add origin ssh://example.com/repos/my_app.git
push local master to remote origin
git push origin master
kill the local temps and re-clone it
cd ..
rm -rf my_app_tmp my_app_clean
git clone svn://example.com/repos/my_app.git
NOW GET TO WORK!