Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use git on existing SVN repo

Tags:

git

svn

git-svn

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?

like image 419
Adam Matan Avatar asked Jun 14 '12 07:06

Adam Matan


People also ask

Can I use Git with a SVN repository?

The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.

How do I clone a SVN repository?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...


2 Answers

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.

like image 152
me_and Avatar answered Sep 19 '22 15:09

me_and


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.

like image 31
greg0ire Avatar answered Sep 22 '22 15:09

greg0ire