Usha Guduri

Getting into the Git Land-via SVN

All the cool kids use git these days but shifting gears for your way-way-back-then-started repo into git is an intimidating task, let alone scaring the entire team while everyone is busy getting their stuff done.

But you still want to learn git? there is no better way to that than using it every single day-isnt that how you became a pro at svn in the first place? so here comes git-svn to the rescue.

Its a real simple tool that goes bi-directional between git and svn and is so well done that sometimes its just prepending git in front of svn commands!

To start a git repo from svn is as easy as

1
$ git svn clone -s http://example.com/subversion_repo local_dir

If your svn repo is not using the standard layout of trunk/branches/tags, you can specify what they are using -T , -b , -t like so

1
$ git svn clone -s http://example.com/my_subversion_repo -T trunk -b my-branch-tree -t my-tag-tree local_dir

Before you start making changes though, you might want to set up the annoying ‘ignores’. Just copy over svn ignore config into git with:

1
$ git svn show-ignore » .git/info/exclude

Ensure your checkout is pointing to the right repo

1
$ git svn info

And now you can start exploring and committing to the local git repo using git commands like

1
2
$ git add my-file
$ git commit my-file

Then comes the slight difference between real git repos and git-svn repos. you most likely heard about git pushing changes. with git-svn, you’d

1
$ git svn dcommit

to push changes to the svn repo. and there you go-you made your first commit to svn via git-irony!!

More to come on .gitconfig, branches, cherry-pick’ing etc. but let me suggest installing bash-completion right away so you can just tab-complete the commands instead of typing out in entirety each time-all about saving those precious strokes that so risk every software engineer to carpal tunnel!

Comments