Manage Symfony with Git
Published February 1, 2008
Using Git to manage Subversion repositories has become very popular the past days - especially in the Django community, where Brian Rosner brought this up in a nice video tutorial.
The biggest advantage of using Git is that you can switch between various branches very easily and nearly instantly - even offline. However, Git's SVN support isn't perfect, so there're also some drawbacks.
The method described here is perfect for testing your project with an older or even a newer version of Symfony.
Installation
If you installed Git over MacPorts, make sure you enabled SVN support:
port -v install git-core +svn
Clone the Symfony repository
The following command will clone the whole symfony SVN repository with all its revisions (over 7000), tags and branches in a folder called symfony.git. This takes some time, so better do something else. You can, however, always cancel and resume the checkout at a later time.
git svn clone -s http://svn.symfony-project.com/ symfony.git
Since all the stuff you just downloaded is taking up quite some space on your hard drive, you might want to run git gc to cleanup unnecessary files and optimize the repository (also takes its time but size went from over 200MB to just 50MB for me).
git gc
In Git, HEAD is always set to the branch where the last commit was made, this could lead to problems. Set it to the 1.0 branch for now:
git reset --hard 1.0
Externals
Of course, the SVN implementation in Git isn't perfect. It mostly shows when using svn:externals which Git doesn't support yet and therefore repositories must be fetched manually. In Symfony's case this is pake and lime.
git svn clone http://svn.symfony-project.com/tools/pake/tags/RELEASE_1_1_5/lib/pake lib/vendor/pake
git svn clone http://svn.symfony-project.com/tools/lime/tags/RELEASE_1_0_4/lib lib/vendor/lime
Finishing up
Create a symlink that links to the Symfony command in our Git repository:
sudo ln -s /Users/arthur/Webdev/symfony.git/data/bin/symfony /usr/bin/symfony_dev
and checkout the latest stable version of Symfony:
git checkout tags/RELEASE_1_0_11
A few branches, like dwhittle, might have a slightly different directory structure. In this case, just adjust your symlink and eventually check out pake and/or lime again - most Symfony branches and tags do have the same layout though.
Remember to run git svn rebase (similar to svn update) once in a while.
git svn rebase

Reply