Using GIT as frontend to SVN
Git is a distributed versioning system gaining popularity. It overcomes many limitations of SVN. Due to the lack of good tooling for Git, it may not be ideal to migrate existing SVN repositories to Git as of today (unless you are comfortable using the command line). However, Git offers a feature to use it as a front-end to existing SVN repositories. The article describes how to setup Git to use with a secured SVN on Windows.
- Install Git from http://code.google.com/p/msysgit/downloads/list
- Download following putty tools from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Set the environment variable GIT_SSH to point to plink.exe.
SET GIT_SSH=c:\Program Files\PuTTY\plink.exe
- Generate public and private keys using PuTTYgen. Contact your system admin to get more details on this and adding your public key to the server
- To get the public key of the server, launch PuTTY, connect to SVN server with the settings below and click Yes to accept the sever’s public key. You can safely close the login window that opens up after accepting the key
- If you already have a private key (for example, openSSH key), use PuTTYgen to import the private key (Conversions > Import) and save it in PuTTY format (File > Save Private Key). If you do not have a key yet you can use PuTTYgen to create a new one.
- Start Pageant. Pageant will display itself as a small icon in the bottom right of the menu bar displaying a computer with a hat
- Right click the icon and add the path to your private key
- Optionally, add Pageant to your Startup menu and modify the Pageant entry to automatically load your private key on startup.
C:\Program Files\PuTTY\pageant.exe “c:\Documents and Settings\username\
- Create a Git repository with
git svn clone <SVN repository> –stdlayout -r <revision>
git svn clone svn+ssh://hugo@myserver/project –stdlayout -r1830
Please note that checking out starting from some revision (for example, 1830 above) is faster.
Leave out the “–stdlayout” option if the respository doesn’t follow the standard SVN trunk-branches-tags structure.
- Fetch from SVN all updates including branches (if any)
git svn fetch
Working with Git
- Now you could make changes to the files and use Git commands to work with the repository. For the complete list of Git commands refer http://git-scm.com/documentation
- To push all changes made back to SVN
git svn dcommit
- To get updates from SVN
git svn rebase
- If SVN has branches and you if would like to create local Git branches connected to the remote SVN branches, do the following steps
git checkout -b <SVN branch name>
git checkout -b mybranch-local mybranch