Mon, 2014/04/07 - 09:59

So... I start in a new place and guess what? They use svn, yeah I know right! After have been working with git for over 3 years thinking none one will still using SVN I'm here... with SVN... again.

Esta en español también!

Warning: I'm not a native / well speaker or talking english guy, so if you see any weird comment or typo, please be nice :)

 

So, it's fine, don't care, I can work with SVN, but, with git of course!

The simple you need to work with git, you don't know what pasta is git? well friend ... go here first.

So, you know git, fine!

Start with the basic

The start, we need to do the "svn checkout" right? let's do it!

git svn clone -s -rN:HEAD -T trunk -b branches -t tags

So this is the most used code (the only?) to do a checkout because the most SVN servers are old or they have some old-version-support settings that help git to understand it. If you need any kind of explanation of this, well ok, I explain this.

The "svn clone" (I'm skiping the git command, guys, c'mon) what this do is the normal "svn checkout ..." or if you are with Windows, is when you do the right click and select the tortoise "SVN checkout..." -s is the short or alias to --stdlayaout what it does, if we read the docu is ... "The option --stdlayout is a shorthand way of setting trunk,tags,branches as the relative paths" this help us with the messy SVN master (trunk) and branches. Then the "-r <n>[:<n>]" it's the revision normally like this -r99:HEAD if you have a big SVN log or repo, may you don't need the full history of it. The rest is easy, -T means --trunk -b branches and -t tags.

So we've now our repo cloned with git and ready to start using it.

You can work normally with git, create a branch, merge it, rebase it, delete it, commit it, but ... not pushing it (;D)

But before explain how to push new code, I'll tell you how to "svn update ." the git repo, because remember we're still working with SVN and it a mess and you need yo pay attention.

git svn rebase

Yes, the "rebase" in the svn plugin means to get the code from the repo and rebase it with our uncommited (svn talking) code. It's simple a quote from the docu "This works similarly to svn update or git pull except that it preserves linear history with git rebase instead of git merge for ease of dcommitting with git svn." so this work like the git rebase but against the SVN repo, working perfect and preserve our code and don't mess the SVN repo.

Now once we did the "git svn rebase" we can push (commit svn talking) our code.

git svn dcommit

And we finally commit our code to the main SVN repo. We're now happy, the SVN admin is happy.

Helpfull commands

Some helpfull commands to keep working with git without no problem

git svn show-ignore >> .git/info/exclude

Full recommended this one ^.

git svn branch waldo

If we need to create a branch in the SVN repo.