Technics‎ > ‎

How To use Git as SubVersion client

Requirements


*nix like Operating system. That means: Linux, BSD, Mac OS X. THIS WON'T WORK ON WINDOWS

Why would I do that??


Let´s start by saying that SubVersion is a great versioning tool. We've been working with it for years and had a great time with it. But it let´s be honest and point out that no tool is perfect and there is always some room for improvement.

Git offers a new approach on code versioning that allows the extra stuff that comes handy when working with traditional code versioning tools: 
  • Local versioning 
  • ability to work with Multiple repositories 
  • traceable branching and merging 
  • offline capabilities 
I don't get to choose the versioning system. If you relate to this, don´t be disappointed! It is possible to combine Git and SVN to enhance it capabilities! We will assume that you already have a subversion repository that you usually work with for this tutorial replace svn_repo_url with the URL of your repository. 

Getting started


Installing git


On your operating system, install git and git-svn (see http://git-scm.com/book/en/Getting-Started-Installing-Git). Once you installed it you should be able to use the git command on your terminal/console.

Checking out your project


To check out your project on svn you would do
svn checkout svn_repo_url

To do this on git-svn you have to type the following command:
git svn clone svn_repo_url

This will create the svn repository as a git repository that you can see locally, and a remote branch that points to the svn_repo_url.

Updating your repository


Before commiting your changes to the repository, aust as you would do with svn update, you can achieve the same by doing a
git svn rebase
this will bring your local repository up to speed with the master (or whichever branch you are in).

Commit your changes


To commit your changes into the repository you just have to make a
git svn dcommit
this will commit your changes into the remote svn repository.