How can I use Git locally in SVN + Visual Studio

I play with git at home and I really like the idea of ​​local commits. The ability to make small changes without spreading my potentially broken code for everyone is good, as well as the ability to undo smaller changes due to more frequent commits.

I read about the git-svn command, but I'm not sure I fully understand how this works. We are working on Visual Studio 2008 projects and launching VisualSVN, which handles file renaming, moving, and everything for us from the IDE.

What I want to know: is it possible for me to commit the local git repository and also pass the remote SVN repository? I would like VisualSVN change tracking and commit from the IDE, but also be able to use git to temporarily save changes. Can they hit each other?

+4
source share
2 answers

I used git-svn to save the β€œupdate” from the remote repository, but did not use it to commit to the svn repository, so I cannot help you with this part.

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

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

When you do this, it pulls it into the "remote" branch called "git-svn". To combine it with the current branch:

 >git merge git-svn 

You may encounter some problems if you use git-svn after the fact. I mean: you already have the project checked with svn, and then you created the git repository in the local svn working directory. Then you use git-svn on top of this.

Two questions I had to deal with:

  • Line endings. svn can convert line endings to windows, and git-svn save them in unix style. This way you can get tons of conflicts due to the difference ending in a line.

    Thus, use a tool to convert line endings for all files to unix (or depending on which line ends in svn repo).

  • The svn keyword extension. e.g. $Id$

    git-svn will not extend these keywords, but svn will not. This way you will also have conflicts. Again, use a tool (or write a script) that converts all instances of $Id .......crap.....$ only to $ Id $ `

+1
source

It works great. Take action. Just don't check the .git folder in svn.

edit: erm, when I do this, I am not worried about git-svn. I simply consider the local svn working directory as any other directory, and I usually do not care about the previous SVN history.

+2
source

All Articles