Thread (9 messages) flat view 9 messages, 3 authors, 2016-06-15

Re: git export to svn

From: Björn Steinbrink <hidden>
Date: 2016-06-15 22:45:32

On 2008.10.26 09:24:07 -0700, Warren Harris wrote:
On Oct 26, 2008, at 2:15 AM, Björn Steinbrink wrote:
quoted
On 2008.10.25 13:29:50 -0700, Warren Harris wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help