18

I work with a legacy svn repo. However, I would like to enjoy the benefits of git on my local machine.

  • The first option is git init the root of my current repo, write code, and independently commit code locally (git commit) and remotely (svn commit).
  • The second option is git-svn, but I don't know if it's worth the troube of learning the nuances of a new tool.

How should I go about this?

4 Answers 4

12

I'd very strongly advocate for git-svn. Myself and some of my colleagues have attempted to use a Git repro over the top of a Subversion one, and it's a process made of pain and horror.

Admittedly this is for Subversion 1.6.x; I suspect it'd be better with 1.7.x, since that only has a single .svn directory.

  • Updating from the repository requires pulling the updates from Subversion, then committing them with Git. That's slow and tedious (admittedly it's fairly slow with git-svn, but at least that automates the process).

    Plus, either you end up downloading every commit with Subversion and committing it manually to Git, or you end up committing bunches of Subversion commits to the Git repository, and $deity help you if you ever want to work on a Subversion revision between your Git commits.

  • Git can't handle empty directories, Subversion requires them for the format of its .svn directories. Which means you need to keep your .svn repositories outside the Git repository, so any git checkout operation will also need a separate svn up.

  • As you note, you'll need to commit everything seperately.

So, using Subversion and Git separately, you'll need to do pretty much every operation in both Git and Subversion. Which means everything takes longer, and you get all the disadvantages of both systems, while they both do a good job of screwing over each other's advantages.

Sign up to request clarification or add additional context in comments.

Comments

6

Use git-svn, it is really simple. First clone your repository with git svn clone then you can git svn dcommit your work or git svn rebase it on the latest changes. Make sure your history is always linear by always rebasing your local branches on master so that you can merge them with git merge --ff-only.

Comments

5

The best way would be migrating to git and throwing away SVN.

However, if that's not an option use git-svn.

When commiting to git/svn separately you'll most likely end up commiting to SVN only very rarely which would result in other developers ending up with huge commits.

2 Comments

If he's writing "I work with a legacy svn repo" probably throwing it away is not really an option
Migrating to git is the only option that is actually good, and add to that something like GitLab. Anyone who's had to go back to SVN after using Git knows it will pay off. I would try to get that through. If not then you are forced to work with poor options.
3

You may try SubGit project. Install SubGit into your SVN repository; a pure Git interface (real Git, not git-svn) for the SVN repository will be created. After that you may use both of the interfaces: SVN or Git for your repository.

If you have no access to your SVN server, there's another option to recommend: SmartGit client. It behaves similar to git-svn but proposes more features (tags, ignores, EOL-handling, cherry-picks).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.