A follow up post to my first Git post has been somewhat delayed by a desire to have a working method to clone my git-svn conversion without losing the metadata needed to commit back to the svn.osafoundation.org. With that hurdle successfully cleared, I’d like to provide a short tutorial on getting Git and setting up a working version of the Cosmo git-svn conversion.
Get Git
The first step is getting Git. A quick Google search reveals a number of howtos and blogs posts about with instructions, so I won’t go into too much detail. A short review of possible methods for OSX can be found here.
MacPorts worked for me:
except that I got tripped up by the difference in install location between the MacPorts perl and the default system version. As of this writing, the MacPorts version is 5.8.8 while the system version is 5.8.6. To find out which you have do:sudo port install git-core +svn
If you suspect you’re using the wrong version, doperl -v
If the MacPorts version of Perl has changed, you might need to change 5.8.8 to the appropriate version number.sudo mv /usr/bin/perl /usr/bin/perl.bak sudo ln -s /opt/local/bin/perl5.8.8 /usr/bin/perl
With the imminent release of OSX Leopard it behooves me to mention that I tested this all on Tiger. I’ll update here once I upgrade the OS.
On my Ubuntu Linux machines apt-get worked like a charm:
To make sure that worked dosudo apt-get install git-svn
git-svn
Git Cosmo
This is the easy part:
git clone git://occident.us/cosmo.git cosmo.git cd cosmo.git git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*' git fetch origin git svn init -t tags -T trunk -b branches svn+ssh://svn.osafoundation.org/svn/server/cosmo/ git svn fetch
These instructions assume you have commit access to the Cosmo Subversion repository. Otherwise, you’ll need to wait until someone makes a git-svn clone using the anonymous repository (it’s on my docket).
I’ve put up a one-off script to run through the above steps here.
Cosmo time!
Time to start being productive again. Here are a few useful commands:
Pull from Subversion
git svn fetchCreate a topic branch from trunk and switch to it
git checkout -b branchname remotes/trunkCommit changes to topic branch
git commitSwitch to trunk
git checkout remotes/trunkMerge topic branch to trunk
git merge branchnameMerge a specific commit
git cherry-pick commit-hashEdit merge commit message
git --amend commitCommit back to Subversion with last commit message
git svn dcommit
I’ll be following up with more examples of how I use Git daily, but these should get you pretty far!
For more in depth information about git-svn use and Git in general, definitely check out Sam Vilain's tutorial.