Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I<sup>1</sup> would like to split the problem into a couple of issues:</p> <ol> <li>Importing Git history into existing Subversion repository;</li> <li>Automatic synchronization of Git and SVN repositories afterwards.</li> </ol> <p>My proposal is based on <a href="http://subgit.com" rel="nofollow">SubGit</a><sup>2</sup>.</p> <h2>Importing Git repository into SVN</h2> <ol> <li><p>If you have local access to Subversion repository at svnserver, the setup is pretty much straight-forward and well documented at <a href="http://subgit.com/book" rel="nofollow">SubGit Book</a>:</p> <p>Let's assume that Subversion repository is located at $SVN_REPO and Git repository is located at $GIT_REPO. First, run the following command:</p> <pre><code>$ subgit configure $SVN_REPO </code></pre> <p>Then adjust generated $SVN_REPO/conf/subgit.conf file as follows:</p> <pre><code> [git "ProjX"] repository = $GIT_REPO translationRoot = /play/me/fromgit/ProjX trunk = trunk:refs/heads/master branches = branches/*:refs/heads/* shelves = shelves/*:refs/shelves/* tags = tags/*:refs/tags/* </code></pre> <p>I'm not quite sure regarding translationRoot option for your case. The value must be a project path relative to SVN repository root, please specify a proper one.</p> <p>Don't forget to remove other 'git' sections, so SubGit won't translate those parts of SVN repository into Git.</p> <p>Optionally you can adjust $SVN_REPO/conf/authors.txt file in order to specify how Git committer names should be translated into SVN author names:</p> <pre><code>SvnAuthor = Git Committer &lt;git.committer@company.com&gt; </code></pre> <p>Finally, import your Git repository into SVN:</p> <pre><code>$ subgit install $SVN_REPO </code></pre> <p>At this moment $SVN_REPO and $GIT_REPO have special hooks installed by SubGit. Subversion and Git servers trigger these hooks on every incoming modification. This way SubGit automatically synchronizes SVN and Git repositories. Created mirror is bi-directional, i.e. some of developers may use SVN clients others may choose any Git clients.</p> <p>In case you don't need such kind of synchronization, just disable it:</p> <pre><code>$ subgit uninstall [--purge] $SVN_REPO </code></pre></li> <li><p>If you don't have local access to Subversion repository, things get much more tricky but still possible:</p> <p>First, fetch the whole SVN repository to your machine, so you can access it locally:</p> <pre><code>$ svnadmin create repo $ svnrdump dump http://me@svnserver/svn/repo | svnadmin load repo </code></pre> <p>Now keep in mind the latest revision of fetched repository:</p> <pre><code>$ svn info file:///path/to/repo Path: repo URL: file:///path/to/repo Repository Root: file:///path/to/repo Repository UUID: cbc56e97-717f-4d50-b705-cb6de2c836eb Revision: $LATEST_REVISION Node Kind: directory Last Changed Author: SvnAuthor Last Changed Rev: $LATEST_REVISION Last Changed Date: 2012-10-27 14:01:38 +0200 (Sat, 27 Oct 2012) </code></pre> <p>Then repeat all the steps from a previous clause. So the local SVN repository should store imported Git history afterwards.</p> <p>Finally, send the generated history back to SVN:</p> <pre><code>$ svnsync initialize http://me@svnserver/svn/repo file://path/to/repo $ svn propset --revprop -r0 svn:sync-last-merged-rev $LATEST_REVISION http://me@svnserver/svn/repo $ svnsync synchronize http://me@svnserver/svn/repo </code></pre> <p>Note that remote repository must have <em>pre-revprop-change</em> hook enabled in order to make svnsync work.</p></li> </ol> <h2>Automatic synchronization of Git and SVN repositories</h2> <ol> <li><p>If you have local access to Subversion repository, you can keep SubGit working after you've installed it. As I already mentioned it translates changes immediately after they were sent to one of repositories, so there's no need to maintain any cron job in this case.</p></li> <li><p>If you have no local access to Subversion repository but still would like to use SubGit, I'd recommend you to use svnsync to synchronize SVN repository hosted at svnserver and SVN repository controlled by SubGit<sup>3</sup>.</p> <p>You may find a guide on how to setup such kind of mirror in <a href="http://blog.subgit.com/git-mirror-of-remote-svn-repo/" rel="nofollow">this HOW-TO</a>.</p> <p>Please note that for this case your project should have a separate Subversion repository, otherwise it's very hard to keep svnsync working properly.</p></li> <li><p>If for any reason you decide to use <code>git-svn</code>, I'd recommend you to create a fresh clone of Subversion repository after you've imported Git history with SubGit:</p> <pre><code>$ git svn init -s http://me@svnserver/svn/repo/play/me/fromgit/ProjX $ git svn fetch </code></pre> <p>From my experience, importing Git history into SVN is not what <code>git-svn</code> was made for. On the other side SubGit handles that well.</p></li> </ol> <p><sup>1</sup> Full disclosure: I'm one of SubGit developers.</p> <p><sup>2</sup> SubGit is a commercial product but it is free for small teams with up to 10 committers. I think it applies for your case.</p> <p><sup>3</sup> Our team is working on SubGit 2.0 which supports synchronization of SVN and Git repositories located on different hosts. Basically, you can create Git repository anywhere and install SubGit into it with SVN URL specified. After that you can work with any of these repositories — changes get translated automatically between them.</p> <p>We're going to publish an EAP build with that functionality, so may try it soon.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload