git + svn

git and svn make a pretty cool combo.

its probably best to start with svn and then create a git to track it , but sometimes its more natural the other way around.

suppose you start a small local project and want to track revs, git is perfect for this as there almost no setup overhead. but when it comes time to distribute / share there are a few things to do to get it up to svn and talking back and forth.

set up the svn repo for sharing the project to, stick with the svn standard layout.


    $ svn mkdir -p svn://repo.example.com/foo/trunk svn://repo.example.com/foo/branches svn://repo.example.com/foo/tags

need to tell git about the remote and start a branch to track from … then we need to


    $ git svn clone svn://repo.example.com/foo -s .

this should get the svn standard layout into git branches. but wait we can’t sync yet, in git we’ve probably been working on the branch master and now we have an empty branch trunk that is synced with svn. so we have to switch our brach to trunk then merge our changes from master to trunk.


   $ git branch
   $ git branch trunk
   $ git merge master

now we will lose our history up to this point but from now on all git commits will equal svn commits once we issue the dcommit command. (there might be some way around this, i couldn’t figure it out, probably not a big deal since its small project getting started.)

 
   $ git svn dcommit 

you may also need to rebase since the svn version is new (although empty) than the master content.
weee! your code should now be accessible from svn check out normally


    $ svn co svn://repo.example.com/foo/trunk foo

had you started with a svn repo and wanted to do some local work using git to talk back and forth this would be much easier …. just follow this post http://tsunanet.blogspot.com/2007/07/learning-git-svn-in-5min.html

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*