A Git User in a SVN World

I’ve been using git as a part of my development workflow for several years now.  The past ten years or so have been a slow progression from subversion to mercurial to git.  I really like all the features that git has to offer and the ease of branching has made my development life much easier.

Every once and awhile, however, I run into a situation where I need to use subversion.  Usually this is because someone else’s code means someone else’s repository of record.

I recently found myself in a situation where asking the organization to migrate from subversion to git just wasn’t feasible.  My next best option was git-svn.  Git-svn is effectively a subversion to git and back to subversion converter of sorts.  You can maintain your git based workflow (slightly modified) and still commit to the organization’s subversion repository.

Frankly, This. Is. Awesome.  Git-svn is included in nearly all git distro deployments (including the XCode CLI from Apple) and is very easy to use.  First, start off with a clone of the subversion repository using git-svn:

git svn clone http://svn-repo.com/svn/repo

This will clone (checkout in subversion parlance) a subversion repository from a remote site to your localhost.  Using this syntax will clone everything from the remote host exactly as is.  Unfortunately, this doesn’t leave much room for branching and tags.  If your remote site is setup with branch, tag, and trunk directories (i.e. http://svn-repo.com/svn/repo/trunk|branch|tag), you can tell git to use the branch directories to emulate git branches using the -s argument:

git svn clone -s http://svn-repo.com/svn/repo

Now your repository is cloned with branching enabled.  You will not see the branch, tag, and trunk directories as they will be emulated in your git repository.

Now you are able to take advantage of your git workflow as usual (adding and commiting) with just a small difference.  If you’d like to send your commits up to the subversion repository, use the command:

git svn dcommit

Your git repository is now uploading your commits to the subversion repository!  For more information, there is a great tutorial on using git-svn at viget.

This entry was posted in computers. Bookmark the permalink.