Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a few issues with your approach:</p> <ul> <li>You seem to be using a pre-existing git repo, rather than one which was initialised via <code>git svn init</code>. Rebasing assumes a common ancestor, but if your git repo was previously initialised via <code>git init</code>, then <code>git svn init</code> will create a second root (i.e. parent-less) commit, and rebasing from one tip to the other will not work without <code>--onto</code>.</li> <li>You use the <code>-s</code> option to <code>git svn init</code>, which causes it to search for <code>branches/</code>, <code>tags/</code>, and <code>trunk/</code>. As the warning (<code>Using higher level...</code>) clearly states, this results in the <code>git-svn</code> config pointing at the top of the svn repo, not the <code>fromgit/ProjX</code> subdirectory.</li> <li>You refer to <code>trunk</code> even though there's no good reason for this branch to exist; <code>git svn init</code> actually creates a tracking branch called <code>remotes/git-svn</code>.</li> </ul> <p>So the actual sequence you want is:</p> <pre><code># 1st time only svn mkdir --parents http://me@svnserver/svn/repo/play/me/fromgit/ProjX mkdir px2 cd px2 git svn init http://me@svnserver/svn/repo/play/me/fromgit/ProjX git svn fetch </code></pre> <p>Now hacking can occur concurrently in git and svn. Next time you want to <code>dcommit</code> from git to svn, you simply do:</p> <pre><code>cd px2 git svn rebase git svn dcommit </code></pre> <p>If you already initialised the git repository, started hacking in it, and need to transplant that history into svn, then the first-time-only sequence is more difficult because you need to transplant all the git history into svn, even though they don't share a common ancestor:</p> <pre><code># 1st time only svn mkdir --parents http://me@svnserver/svn/repo/play/me/fromgit/ProjX git clone ssh://me@gitserver/git-repo/Projects/ProjX px2 cd px2 git svn init http://me@svnserver/svn/repo/play/me/fromgit/ProjX git svn fetch # transplant original git branch onto git-svn branch root_commit=$( git rev-list --reverse HEAD | head -n1 ) git tag original-git git reset --hard $root_commit git reset --soft git-svn git commit -C $root_commit # N.B. this bit requires git &gt;= 1.7.2 git cherry-pick $root_commit..original-git # For older gits you could do # git rev-list $root_commit..original-git | xargs -n1 git cherry-pick # or use git rebase --onto but that requires jumping through some # hoops to stop moving remotes/git-svn. </code></pre> <p>Subsequently, do the same <code>svn rebase</code> and <code>dcommit</code> as before.</p> <p>In case anyone wants to test this approach in a sandbox, you can download <a href="https://gist.github.com/cf334fc594e7f9fab988" rel="noreferrer">my test script</a>. I'd recommend you do a visual security audit before running though ;-)</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