Re: git export to svn

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Björn
Date: Sunday, October 26, 2008 - 10:15 am

On 2008.10.26 09:24:07 -0700, Warren Harris wrote:

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?


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.


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
--
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
git export to svn, Warren Harris, (Sat Oct 25, 11:40 am)
Re: git export to svn, J.H., (Sat Oct 25, 11:43 am)
Re: git export to svn, Warren Harris, (Sat Oct 25, 12:11 pm)
Re: git export to svn, J.H., (Sat Oct 25, 1:12 pm)
Re: git export to svn, Warren Harris, (Sat Oct 25, 1:29 pm)
Re: git export to svn, Björn, (Sun Oct 26, 2:15 am)
Re: git export to svn, Warren Harris, (Sun Oct 26, 9:24 am)
Re: git export to svn, Björn, (Sun Oct 26, 10:15 am)
Re: git export to svn, Warren Harris, (Tue Oct 28, 8:40 pm)