svn2git for real men
By kenglish
On the server, set up the remote repositories:
1 2 3 | mkdir project1.git cd project1.git git --bare init |
Here’s a script to do them all in one shot, just modifiy the REPOS variable:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/sh REPOS="project1 project2 project3 project4" for repo in $REPOS do repo_dir="$repo.git" mkdir -p $repo_dir echo "Creating git directory $repo_dir" cd $repo_dir git --bare init cd .. done exit |
Now, on the workstation:
1 2 | sudo apt-get install git-core git-svn sudo gem install nirvdrum-svn2git --source http://gems.github.com |
Create the authors.txt in the following format:
1 2 | dburger = David Burger <email@email.com> jdoe = John Doe <jdoe@doe.com> |
For one project, do the following:
1 2 3 4 5 | mkdir project1 cd project1 svn2git https://svn.myserver.org/repos/ses --authors ../authors.txt git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/ses.git git push --all |
The script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #!/bin/sh REPOS="project1 project2 project3 project4" for repo in $REPOS do mkdir $repo cd $repo cmd="svn2git https://svn.myserver.org/repos/$repo --authors ../authors.txt" echo $cmd `$cmd` cmd="git remote add origin hailstorm.myserver.org:/home/kenglish/repotest/$repo.git" echo $cmd `$cmd` cmd="git push --all" echo $cmd `$cmd` cd .. echo "DONE EXPORTING $repo" done exit |
Don’t diss the shell script, I leave in the echoes in case i need to test stuff out…
Note: Another option for the authors file is place it in your home directory .svn2git/authors (e.g. /home/kenglish/.svn2git/authors). Svn2git will automatically detect it and use it.
Any questions? Comments?
git , svn 


May 21st, 2009
Seth Ladd
May 24th, 2009
this is tight.
Nick
October 23rd, 2009
Try using #!/bin/sh -x or “set -x” within the body of your shell script, near the beginning. It’ll echo every command that gets executed. No more need for echoing. Also, -e will exit on the first failed command, which is also very useful sometimes.