Migrate a svn-trac development setup to git January 6th, 2009
I got tired of svn for my rails development, because most of the rails community has moved to git, and it gets very hard to manage the vendor dependancies —and also rails edge— which are on a git repository while you are using a svn repository.
I heard of Piston. I used to use Piston a lot and it is great to track the vendor branches under svn, but it just doesn’t play well with the git vendor branches. Piston 2 should fix this though, but to date, its development is at an early stage.
So well, I heard git ain’t too bad either. And Braid allows to do the same than Piston with git repositories. Migrating svn to git was painless, I had a bit more difficulties making trac work nicely with git, so I wrote some notes about it.
Migrate svn
It’s easy. First create a users.txt file to map your svn users with your git users.
vim users.txt
And type:
edouard = Edouard Briere anotheruser = Another Name
Then, you will need to actually install git and git-svn.
sudo apt-get install git git-svn
Then run the folowing commands:
mkdir my_project_git_svn cd my_project_git_svn git-svn init http://url.to.your.svn.project.com/trunk/ --no-metadata git config svn.authorsfiles ../users.txt git-svn fetch
That’s it! We just created a temporary git-svn repository. git-svn is now fetching all the svn changesets and import them into the new git repository. It can take quite some time, depending on the size of your project.
Now, we don’t want a git-svn repository but a git repository. Let’s change this.
git clone my_project_git_svn my_project_git
Done! You can now clean up. I kept my old svn repository, but I guess you can delete it if you wish, you can delete the git-svn repository for sure, you won’t need it.
rm -rf my_project_git_svn
Setting up trac 0.11
Now, configuring trac is not as fun. First, get the GitPlugin.
cd ~/src svn co http://trac-hacks.org/svn/gitplugin cd gitplugin/0.11 export PYTHONPATH=~/lib/python2.5/site-packages:$PYTHONPATH python setup.py install
Go to your trac project directory. I put mine in /var/lib/trac/my_project. Edit your conf/trac.ini as such:
[components] tracext.git.* = enabled [trac] repository_dir = /path/to/repository/your_project/.git/ repository_type = git [git] cached_repository = true persistent_cache = true shortrev_len = 6 git_bin = /usr/bin/git
Then, you need to resync the trac changeset cache against your repository
sudo trac-admin translator resyncand restart Apache.
sudo apache2 -k restart. And voilà!
May be useful
Git for SVN users crash course
/ Tags: System, trac, svn, git Trackback



