git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Warren Harris <warrensomebody@gmail.com>
To: "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: "J.H." <warthog19@eaglescrag.net>, git@vger.kernel.org
Subject: Re: git export to svn
Date: Tue, 28 Oct 2008 20:40:21 -0700	[thread overview]
Message-ID: <9CE5F946-B783-4D0F-993B-C0187E2E2DAF@gmail.com> (raw)
In-Reply-To: <20081026171519.GD3612@atjola.homenet>

Björn - Thanks again for your help...

On Oct 26, 2008, at 10:15 AM, Björn Steinbrink wrote:

>>
>> Since I'm trying to export my git repo to svn, the svn repo is
>> completely empty.
>
> OK, the "r58084" made me think that your code is based on something  
> that
> is already in the SVN repo. But apperently, that's just a shared svn
> repo, right?

Right

>
> This should do and uses a graft to simplify the process a bit:
>
> Initialize git-svn:
> git svn init -s --prefix=svn/ https://svn/svn/SANDBOX/warren/test2
>
> The --prefix gives you remote tracking branches like "svn/trunk" which
> is nice because you don't get ambiguous names if you call your local
> branch just "trunk" then. And -s is a shortcut for the standard
> trunk/tags/branches layout.
>
>
> Fetch the initial stuff from svn:
> git svn fetch
>
> Now look up the hash of your root commit (should show a single  
> commit):
> git rev-list --parents master | grep '^.\{40\}$'
>
> Then get the hash of the empty trunk commit:
> git rev-parse svn/trunk
>
> Create the graft:
> echo <root-commit-hash> <svn-trunk-commit-hash> >> .git/info/grafts
>
> Now, "gitk" should show svn/trunk as the first commit on which your
> master branch is based.
>
> Make the graft permanent:
> git filter-branch -- ^svn/trunk --all
>
> Drop the graft:
> rm .git/info/grafts
>
> gitk should still show svn/trunk in the ancestry of master
>
> Linearize your history on top of trunk:
> git svn rebase
>
> And now "git svn dcommit -n" should tell you that it is going to  
> commit
> to trunk.

This worked. The only downside was that all of our svn users  
subscribed to the checkins mailing list got a flood of messages from  
me, but otherwise it worked like a charm. (I see that the original git  
commit dates were not preserved in svn, but that doesn't matter too  
much...)

>
>
>
> Alternatively, if rebase gives just too many conflicts, you can do:
>
> git svn init -s --prefix=svn/ https://svn/svn/SANDBOX/warren/test2
> git svn fetch
> git checkout -b trunk svn/trunk
> git merge master
> git svn dcommit
>
> That will just create a single huge commit in svn. But the history  
> will
> be retained in git. You can then work on the new "trunk" branch or  
> move
> your master branch, so it points to the same commit as trunk and then
> drop the "trunk" branch or whatever. It just matters that your new  
> work
> is based upon the dcommited merge commit, so "svn/trunk" is in your
> branch's history.

This didn't work for me. (I had tried the first procedure on a test  
tree, then this one on a different test tree, and ultimately went back  
to the first procedure for my real git repo.) I ended up with an empty  
svn tree. For the record, here's what happened:

$ git svn fetch
W: Ignoring error from SVN, path probably does not exist: (175002): RA  
layer request failed: REPORT of '/svn/!svn/bc/100': Could not read  
chunk size: Secure connection truncated (https://svn)
W: Do not be alarmed at the above message git-svn is just searching  
aggressively for old history.
This may take a while on large repositories
r58382 = 9b9d5f01e4a3aca714eb5f61a9f05ab657cc7bc5 (svn/trunk)
Checked out HEAD:
   https://svn/svn/test3/trunk r58382

$ git checkout -b trunk svn/trunk
Switched to a new branch "trunk"

$ git merge master
Already up-to-date.

$ git svn dcommit
Committing to https://svn/svn/test3/trunk ...

$ cd tmp/svn-test3/

$ svn co https://svn/svn/test3/trunk
Checked out revision 58385.

$ ls -al trunk/
total 88
drwxr-xr-x  11 warren  staff    374 Oct 28 18:15 .
drwxr-xr-x   3 warren  staff    102 Oct 28 18:15 ..
drwxr-xr-x   9 warren  staff    306 Oct 28 18:15 .svn


Now one thing that might be different than what you prescribed is that  
our svn repo uses different conventions for branches and tags, so I  
didn't use 'git svn init -s', although I doubt that matters.

Anyway, I'm up and running in svn with your first procedure, so my  
problem is solved. Thanks.

Warren

      reply	other threads:[~2008-10-29  3:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-25 18:40 git export to svn Warren Harris
2008-10-25 18:43 ` J.H.
2008-10-25 19:11   ` Warren Harris
2008-10-25 20:12     ` J.H.
2008-10-25 20:29       ` Warren Harris
2008-10-26  9:15         ` Björn Steinbrink
2008-10-26 16:24           ` Warren Harris
2008-10-26 17:15             ` Björn Steinbrink
2008-10-29  3:40               ` Warren Harris [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9CE5F946-B783-4D0F-993B-C0187E2E2DAF@gmail.com \
    --to=warrensomebody@gmail.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=warthog19@eaglescrag.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).