git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git export to svn
@ 2008-10-25 18:40 Warren Harris
  2008-10-25 18:43 ` J.H.
  0 siblings, 1 reply; 9+ messages in thread
From: Warren Harris @ 2008-10-25 18:40 UTC (permalink / raw)
  To: git

Is there a way to export a git repository along with its history to  
svn? (git svn init seems to want to go in the other direction.) I know  
this is in some sense "going backwards" but I need to commit my work  
to a client. Thanks,

Warren

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  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
  0 siblings, 1 reply; 9+ messages in thread
From: J.H. @ 2008-10-25 18:43 UTC (permalink / raw)
  To: Warren Harris; +Cc: git

The basic way you would want to do it, it attach your git tree to SVN
and then git svn dcommit - which will replay the uncommitted changes
back into SVN - git svn init will do the attachment - assuming that your
git / svn repositories are at least based from the same place.

- John 'Warthog9' Hawley

On Sat, 2008-10-25 at 11:40 -0700, Warren Harris wrote:
> Is there a way to export a git repository along with its history to  
> svn? (git svn init seems to want to go in the other direction.) I know  
> this is in some sense "going backwards" but I need to commit my work  
> to a client. Thanks,
> 
> Warren
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-25 18:43 ` J.H.
@ 2008-10-25 19:11   ` Warren Harris
  2008-10-25 20:12     ` J.H.
  0 siblings, 1 reply; 9+ messages in thread
From: Warren Harris @ 2008-10-25 19:11 UTC (permalink / raw)
  To: J.H.; +Cc: git

John,

Thanks for your quick reply. I tried that, but got the following error:


$ git clone ../test2/
Initialized empty Git repository in /Users/warren/projects/tmp/test2- 
git-clone/test2/.git/
# ...svn test2 dir already created with subdirs trunk, tags and  
branches...
$ git svn init https://svn/svn/SANDBOX/warren/test2 -T trunk -t tags - 
b branches
Using higher level of URL: https://svn/svn/SANDBOX/warren/test2 => https://svn/svn
$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.

I then tried the hints from here: http://www.basementcoders.com/2008/9/30/git-svn-gotcha 
, but still no luck:

$ git merge --no-ff master
Already up-to-date.
$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.


Warren


On Oct 25, 2008, at 11:43 AM, J.H. wrote:

> The basic way you would want to do it, it attach your git tree to SVN
> and then git svn dcommit - which will replay the uncommitted changes
> back into SVN - git svn init will do the attachment - assuming that  
> your
> git / svn repositories are at least based from the same place.
>
> - John 'Warthog9' Hawley
>
> On Sat, 2008-10-25 at 11:40 -0700, Warren Harris wrote:
>> Is there a way to export a git repository along with its history to
>> svn? (git svn init seems to want to go in the other direction.) I  
>> know
>> this is in some sense "going backwards" but I need to commit my work
>> to a client. Thanks,
>>
>> Warren
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-25 19:11   ` Warren Harris
@ 2008-10-25 20:12     ` J.H.
  2008-10-25 20:29       ` Warren Harris
  0 siblings, 1 reply; 9+ messages in thread
From: J.H. @ 2008-10-25 20:12 UTC (permalink / raw)
  To: Warren Harris; +Cc: git

Even with init - your going to need to do a fetch so that you have a
copy of the svn in your tree - if the git tree you've already got has
the svn references (take a look at git-log if it seems to have an svn
line in the log then at some point someone pulled in the svn tree into
git) if not your going to effectively be pulling the entire svn tree
into your git tree.

The only other real way to get your changes / patches into svn is to
dump them out as patches and them individually apply / commit them to
your svn tree.

- John 'Warthog9' Hawley


On Sat, 2008-10-25 at 12:11 -0700, Warren Harris wrote:
> John,
> 
> Thanks for your quick reply. I tried that, but got the following error:
> 
> 
> $ git clone ../test2/
> Initialized empty Git repository in /Users/warren/projects/tmp/test2- 
> git-clone/test2/.git/
> # ...svn test2 dir already created with subdirs trunk, tags and  
> branches...
> $ git svn init https://svn/svn/SANDBOX/warren/test2 -T trunk -t tags - 
> b branches
> Using higher level of URL: https://svn/svn/SANDBOX/warren/test2 => https://svn/svn
> $ git svn dcommit
> Can't call method "full_url" on an undefined value at /opt/local/ 
> libexec/git-core/git-svn line 425.
> 
> I then tried the hints from here: http://www.basementcoders.com/2008/9/30/git-svn-gotcha 
> , but still no luck:
> 
> $ git merge --no-ff master
> Already up-to-date.
> $ git svn dcommit
> Can't call method "full_url" on an undefined value at /opt/local/ 
> libexec/git-core/git-svn line 425.
> 
> 
> Warren
> 
> 
> On Oct 25, 2008, at 11:43 AM, J.H. wrote:
> 
> > The basic way you would want to do it, it attach your git tree to SVN
> > and then git svn dcommit - which will replay the uncommitted changes
> > back into SVN - git svn init will do the attachment - assuming that  
> > your
> > git / svn repositories are at least based from the same place.
> >
> > - John 'Warthog9' Hawley
> >
> > On Sat, 2008-10-25 at 11:40 -0700, Warren Harris wrote:
> >> Is there a way to export a git repository along with its history to
> >> svn? (git svn init seems to want to go in the other direction.) I  
> >> know
> >> this is in some sense "going backwards" but I need to commit my work
> >> to a client. Thanks,
> >>
> >> Warren
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe git" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-25 20:12     ` J.H.
@ 2008-10-25 20:29       ` Warren Harris
  2008-10-26  9:15         ` Björn Steinbrink
  0 siblings, 1 reply; 9+ messages in thread
From: Warren Harris @ 2008-10-25 20:29 UTC (permalink / raw)
  To: J.H.; +Cc: git

I tried a fetch, but still no luck:

$ 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
r58084 = c01dadf89b552077da132273485e7569d8694518 (trunk)
	A	...
r58088 = 7916f3a02ad6c759985bd9fb886423c373a72125 (trunk)

$ git svn rebase
Unable to determine upstream SVN information from working tree history

$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.


Looks like the only option is applying individual patches to preserve  
my history...

Warren


On Oct 25, 2008, at 1:12 PM, J.H. wrote:

> Even with init - your going to need to do a fetch so that you have a
> copy of the svn in your tree - if the git tree you've already got has
> the svn references (take a look at git-log if it seems to have an svn
> line in the log then at some point someone pulled in the svn tree into
> git) if not your going to effectively be pulling the entire svn tree
> into your git tree.
>
> The only other real way to get your changes / patches into svn is to
> dump them out as patches and them individually apply / commit them to
> your svn tree.
>
> - John 'Warthog9' Hawley
>
>
> On Sat, 2008-10-25 at 12:11 -0700, Warren Harris wrote:
>> John,
>>
>> Thanks for your quick reply. I tried that, but got the following  
>> error:
>>
>>
>> $ git clone ../test2/
>> Initialized empty Git repository in /Users/warren/projects/tmp/test2-
>> git-clone/test2/.git/
>> # ...svn test2 dir already created with subdirs trunk, tags and
>> branches...
>> $ git svn init https://svn/svn/SANDBOX/warren/test2 -T trunk -t  
>> tags -
>> b branches
>> Using higher level of URL: https://svn/svn/SANDBOX/warren/test2 => https://svn/svn
>> $ git svn dcommit
>> Can't call method "full_url" on an undefined value at /opt/local/
>> libexec/git-core/git-svn line 425.
>>
>> I then tried the hints from here: http://www.basementcoders.com/2008/9/30/git-svn-gotcha
>> , but still no luck:
>>
>> $ git merge --no-ff master
>> Already up-to-date.
>> $ git svn dcommit
>> Can't call method "full_url" on an undefined value at /opt/local/
>> libexec/git-core/git-svn line 425.
>>
>>
>> Warren
>>
>>
>> On Oct 25, 2008, at 11:43 AM, J.H. wrote:
>>
>>> The basic way you would want to do it, it attach your git tree to  
>>> SVN
>>> and then git svn dcommit - which will replay the uncommitted changes
>>> back into SVN - git svn init will do the attachment - assuming that
>>> your
>>> git / svn repositories are at least based from the same place.
>>>
>>> - John 'Warthog9' Hawley
>>>
>>> On Sat, 2008-10-25 at 11:40 -0700, Warren Harris wrote:
>>>> Is there a way to export a git repository along with its history to
>>>> svn? (git svn init seems to want to go in the other direction.) I
>>>> know
>>>> this is in some sense "going backwards" but I need to commit my  
>>>> work
>>>> to a client. Thanks,
>>>>
>>>> Warren
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe git" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-25 20:29       ` Warren Harris
@ 2008-10-26  9:15         ` Björn Steinbrink
  2008-10-26 16:24           ` Warren Harris
  0 siblings, 1 reply; 9+ messages in thread
From: Björn Steinbrink @ 2008-10-26  9:15 UTC (permalink / raw)
  To: Warren Harris; +Cc: J.H., git

On 2008.10.25 13:29:50 -0700, Warren Harris wrote:
> I tried a fetch, but still no luck:
>
> $ 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
> r58084 = c01dadf89b552077da132273485e7569d8694518 (trunk)
> 	A	...
> r58088 = 7916f3a02ad6c759985bd9fb886423c373a72125 (trunk)
>
> $ git svn rebase
> Unable to determine upstream SVN information from working tree history

Means that your current branch is not based on what git-svn has fetched,
which is expected when you use "svn init" + "svn fetch" after you
already started working.

What's the actual relationship between your local history and the
history you fetched from svn?

If your local stuff started from revision X, which you manually imported
from svn, you can just rebase it:

git rebase --onto <svn-revision-X> <your-revision-X>


If you have a bunch of merges in your local history, you might want to
merge your stuff into the svn-based branch instead. When you dcommit,
the svn repo will only see one big "do it all" commit though.

For that, you would create a graft, so that your first "real" local
commit gets the svn revision X commit as its parent. That is, from:

S---S---SX---S---S---S (svn)

LX--------L---L---L---L (local)

You want to go to:

S---S---SX---S---S---S (svn)
         \
LX        L---L---L---L (local)


Where 'S' means that the commit came from SVN, and L means that it is a
"local" commit. SX and LX are the commits that have the same tree
attached (same directories/files), but have a different hash due to how
they were created. The graft overrides the parent-child relation for the
first "L" commit, so that it actually appears as being branched off of SX.

And then, you'd merge local into svn, so you get:

S---S---SX---S---S---S--M (svn)
         \             /
LX        L---L---L---L (local)



If possible, go with the rebase though. That at least gives a somewhat
reasonable history in the svn repo as well. Also note that when you go
with the merge way, make sure that the svn branch is totally uptodate
before you merge and that the merge commit is the only one to be
dcommitted. Otherwise, funny stuff might happen, and rebase might kick
in anyway, I don't exactly remember what git-svn does, but it wasn't
pleasant :-)

Björn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-26  9:15         ` Björn Steinbrink
@ 2008-10-26 16:24           ` Warren Harris
  2008-10-26 17:15             ` Björn Steinbrink
  0 siblings, 1 reply; 9+ messages in thread
From: Warren Harris @ 2008-10-26 16:24 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: J.H., git


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

> On 2008.10.25 13:29:50 -0700, Warren Harris wrote:
>> I tried a fetch, but still no luck:
>>
>> $ 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
>> r58084 = c01dadf89b552077da132273485e7569d8694518 (trunk)
>> 	A	...
>> r58088 = 7916f3a02ad6c759985bd9fb886423c373a72125 (trunk)
>>
>> $ git svn rebase
>> Unable to determine upstream SVN information from working tree  
>> history
>
> Means that your current branch is not based on what git-svn has  
> fetched,
> which is expected when you use "svn init" + "svn fetch" after you
> already started working.
>
> What's the actual relationship between your local history and the
> history you fetched from svn?

Since I'm trying to export my git repo to svn, the svn repo is  
completely empty.

>
>
> If your local stuff started from revision X, which you manually  
> imported
> from svn, you can just rebase it:
>
> git rebase --onto <svn-revision-X> <your-revision-X>

When I try this, I keep getting:

fatal: Needed a single revision
invalid upstream

>
>
>
> If you have a bunch of merges in your local history, you might want to
> merge your stuff into the svn-based branch instead. When you dcommit,
> the svn repo will only see one big "do it all" commit though.
>
> For that, you would create a graft, so that your first "real" local
> commit gets the svn revision X commit as its parent. That is, from:
>
> S---S---SX---S---S---S (svn)
>
> LX--------L---L---L---L (local)
>
> You want to go to:
>
> S---S---SX---S---S---S (svn)
>         \
> LX        L---L---L---L (local)
>
>
> Where 'S' means that the commit came from SVN, and L means that it  
> is a
> "local" commit. SX and LX are the commits that have the same tree
> attached (same directories/files), but have a different hash due to  
> how
> they were created. The graft overrides the parent-child relation for  
> the
> first "L" commit, so that it actually appears as being branched off  
> of SX.
>
> And then, you'd merge local into svn, so you get:
>
> S---S---SX---S---S---S--M (svn)
>         \             /
> LX        L---L---L---L (local)
>
>
>
> If possible, go with the rebase though. That at least gives a somewhat
> reasonable history in the svn repo as well. Also note that when you go
> with the merge way, make sure that the svn branch is totally uptodate
> before you merge and that the merge commit is the only one to be
> dcommitted. Otherwise, funny stuff might happen, and rebase might kick
> in anyway, I don't exactly remember what git-svn does, but it wasn't
> pleasant :-)


I may not have been clear about what I'm trying to do: I have a git  
repository, and I'd like to put it (either the head of the master, or  
the entire revision history if possible) into svn. From then on, I  
would like to be able to use 'git svn' commands to manage the two  
repos. (Initially I don't expect anyone else to be committing to svn  
-- it's just an archive and something for others to pull from.)

Here's a complete transcript of how I tried to do this, which seems to  
be missing some crucial step:

$ mkdir test2-git-clone
$ git clone ../test2/   # clone my working repo which is unrelated to  
svn at this point
$ cd test2-git-clone/test2
$ svn mkdir https://svn/svn/SANDBOX/warren/test2 -m "test2"
$ svn mkdir https://svn/svn/SANDBOX/warren/test2/trunk -m "test2"
$ svn mkdir https://svn/svn/SANDBOX/warren/test2/branches -m "test2"
$ svn mkdir https://svn/svn/SANDBOX/warren/test2/tags -m "test2"
$ git svn init https://svn/svn/SANDBOX/warren/test2 -T trunk -t tags - 
b branches
Initialized empty Git repository in /Users/warren/projects/tmp/test2- 
git-clone/test2/.git/
Using higher level of URL: https://svn/svn/SANDBOX/warren/test2 => https://svn/svn
$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.
$ git merge --no-ff master
Already up-to-date.
$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.
$ git svn fetch
$ git svn dcommit
Can't call method "full_url" on an undefined value at /opt/local/ 
libexec/git-core/git-svn line 425.


Thanks for your help,

Warren

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-26 16:24           ` Warren Harris
@ 2008-10-26 17:15             ` Björn Steinbrink
  2008-10-29  3:40               ` Warren Harris
  0 siblings, 1 reply; 9+ messages in thread
From: Björn Steinbrink @ 2008-10-26 17:15 UTC (permalink / raw)
  To: Warren Harris; +Cc: J.H., git

On 2008.10.26 09:24:07 -0700, Warren Harris wrote:
>
> On Oct 26, 2008, at 2:15 AM, Björn Steinbrink wrote:
>
>> On 2008.10.25 13:29:50 -0700, Warren Harris wrote:
>>> I tried a fetch, but still no luck:
>>>
>>> $ 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
>>> r58084 = c01dadf89b552077da132273485e7569d8694518 (trunk)
>>> 	A	...
>>> r58088 = 7916f3a02ad6c759985bd9fb886423c373a72125 (trunk)
>>>
>>> $ git svn rebase
>>> Unable to determine upstream SVN information from working tree  
>>> history
>>
>> Means that your current branch is not based on what git-svn has  
>> fetched,
>> which is expected when you use "svn init" + "svn fetch" after you
>> already started working.
>>
>> What's the actual relationship between your local history and the
>> history you fetched from svn?
>
> 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?

> I may not have been clear about what I'm trying to do: I have a git  
> repository, and I'd like to put it (either the head of the master, or  
> the entire revision history if possible) into svn. From then on, I would 
> like to be able to use 'git svn' commands to manage the two repos. 
> (Initially I don't expect anyone else to be committing to svn -- it's 
> just an archive and something for others to pull from.)
>
> Here's a complete transcript of how I tried to do this, which seems to  
> be missing some crucial step:
>
> $ mkdir test2-git-clone
> $ git clone ../test2/   # clone my working repo which is unrelated to  
> svn at this point
> $ cd test2-git-clone/test2
> $ svn mkdir https://svn/svn/SANDBOX/warren/test2 -m "test2"
> $ svn mkdir https://svn/svn/SANDBOX/warren/test2/trunk -m "test2"
> $ svn mkdir https://svn/svn/SANDBOX/warren/test2/branches -m "test2"
> $ svn mkdir https://svn/svn/SANDBOX/warren/test2/tags -m "test2"
> $ git svn init https://svn/svn/SANDBOX/warren/test2 -T trunk -t tags -b 
> branches
> Initialized empty Git repository in /Users/warren/projects/tmp/test2- 
> git-clone/test2/.git/
> Using higher level of URL: https://svn/svn/SANDBOX/warren/test2 => https://svn/svn
> $ git svn dcommit
> Can't call method "full_url" on an undefined value at /opt/local/ 
> libexec/git-core/git-svn line 425.

Can't work yet, your local stuff is not yet connected to the svn commit
(which you didn't even fetch yet). Same for the other dcommit calls you
did.

> $ git merge --no-ff master
> Already up-to-date.

That tries to merge master into itself ;-) The blog entry assumed that
you have a svn-based branch checked out, and applies to quite a
different situation.



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.


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.

HTH
Björn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git export to svn
  2008-10-26 17:15             ` Björn Steinbrink
@ 2008-10-29  3:40               ` Warren Harris
  0 siblings, 0 replies; 9+ messages in thread
From: Warren Harris @ 2008-10-29  3:40 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: J.H., git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-10-29  3:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).