views:

281

answers:

2

I've been playing around with git at home and I really like the idea of local commits. Being able to commit smaller changes without spreading my potentially broken code to everyone is nice, as well as being able to revert smaller changes because of the more frequent commits.

I've been reading about the git-svn command, but I'm not sure I entirely understand how it works. We work on Visual Studio 2008 projects, and run VisualSVN which handles file renames, moves, and all that for us from within the IDE.

What I want to know is: Is it possible for me to commit to a local git repository but also commit to the remote SVN repository as well? I'd like to keep VisualSVN change tracking and committing from within the IDE, but also be able to use git to temporarily store changes. Are they likely to get in each other's way?

+1  A: 

It works beautifully. go for it. Just don't check your .git folder into svn.

edit: erm, when I do it though, I don't bother with git-svn. I just treat the local working directory for svn as any other directory, and I tend not to care much about the previous SVN history.

Breton
Cool, I'd kind of like to get the previous SVn history into git but it is not a deal breaker.
Jamie Penney
+1  A: 

I've used git-svn to keep "updating" from the remote repository, but haven't used it to commit to an svn repository, so I can't help you about that part.

What you do is simple, with all settings on default:

>git svn init <url......>
>git svn fetch

When you do that, it fetches it to a "remote" branch called "git-svn". To merge it with your current branch:

>git merge git-svn

You may run into some issues if you're using git-svn after the fact. What I mean by that is: you already have checkout the project using svn, then you also created a git repository in your local working svn directory. Then you use git-svn on top of that.

Two issues I had to deal with:

  1. Line endings. svn might convert line endings to windows, while git-svn will preserve them to unix style. So you might get tons of conflicts due to the line ending differences.

    So to be sure, use a tool to convert line endings on all files to unix (or windows, depending on what line ending is used in the svn repo).

  2. svn keyword expansion. e.g. $Id$

    git-svn will not expand these keywords, while svn will. So you'll have conflicts there as well. Again, use a tool (or write a script) that converts all instances of $Id .......crap.....$ to just $Id$`

hasen j