15

Subversion was popular several years ago, now git is becoming popular and more and more people want to replace Subversion with git.

Problem is that a lot projects were based on Subversion. So question is how to use git together with Subversion. Do not replace svn completely, and use git.

The simplest way I can figure out is to create git based on the Subversion branch code you have already checked out. Then use git to control locally. After modifications, submit to local git server, then check out to remote server with Subversion. Subversion is just like container to contain git.

BTW, I am coding with xcode 3.x , try xcode 4 before, but disappointed. ( Xcode 4 has come out now, but no retry yet)

How do you think ? Or any better choices ?

Thanks

user229044
  • 232,980
  • 40
  • 330
  • 338
Forrest
  • 122,703
  • 20
  • 73
  • 107

2 Answers2

6

Subversion is just like container to contain git

Be sure to read the CAVEATS section coming with git-svn:

CAVEATS

For the sake of simplicity and interoperating with a less-capable system (SVN), it is recommended that all git svn users clone, fetch and dcommit directly from the SVN server, and avoid all git clone/pull/merge/push operations between git repositories and branches.
The recommended method of exchanging code between git branches and users is git format-patch and git am, or just 'dcommit’ing to the SVN repository.

Running git merge or git pull is NOT recommended on a branch you plan to dcommit from.
Subversion does not represent merges in any reasonable or useful fashion; so users using Subversion cannot see any merges you’ve made. Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommit may commit to the wrong branch.

So you can adopt any merge and publication workflow with Git, as long as you leave the SVN branches you mirror alone (in term of merges or rebases).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • To my ears, that sounds like, "If you want to use svn, use svn." Which is bad. – lprsd Mar 14 '11 at 05:35
  • @Lakshman: it only means that not all actions on Git can be safely mirrored on SVN. Still that double Git-SVN can make sense when centralized servers depends on SVN for official repositories, while development tasks can go on using Git. – VonC Mar 14 '11 at 06:30
  • actually in my case, I am not going to use git-svn, I just create git repository from codes which were checked out by svn. Because when I used git-svn clone command,it was so slow and finally can not check them out successfully. But it was always to check out correctly just with svn. – Forrest Mar 14 '11 at 08:50
  • @Forrest: this can work too, even though the integration isn't as tight as a `git-svn`. – VonC Mar 14 '11 at 08:59
6

I've created a collection of how-to's and screencasts on how to use git-svn here:

http://www.tfnico.com/presentations/git-and-subversion

Among them you'll find a git-svn mirror setup. It's a bit of effort to understand and set up, but it's been working for me for nearly a year, with a fairly large SVN repository.

Update: An easy and valuable practice is to always initialize git-svn clones with the --prefix option. I've explained why here.

Thomas Ferris Nicolaisen
  • 5,036
  • 2
  • 30
  • 36