[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Converting a proprietary svn repository to git
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Converting a proprietary svn repository to git |
Date: |
Wed, 2 Mar 2016 15:10:39 +0100 |
On Tue, 1 Mar 2016 16:17:17 +0000 Greg Chicares <address@hidden> wrote:
GC> There is one imperfection: in the final step, I had to specify the branch:
GC> git clone -b master file:///tmp/migration/blessed/proprietary
GC> ^^^^^^^^^
GC> Without it, the command above gives:
GC> remote HEAD refers to nonexistent ref, unable to checkout
This is because HEAD is a link to svn trunk branch, which, as far as git
is concerned, is not a real branch. But I don't understand why doesn't it
point to master.
GC> I thought 'clone' was normally expected to work without specifying a branch,
Only because normally HEAD points to a branch. In this case it doesn't, so
clone behaves perfectly logically.
GC> [0] "the script pasted below"
GC>
GC> -------------------------------------8<-------------------------------------
GC> #!/bin/bash
GC>
GC> # migrate a particular svn repository to git
...
GC> # create a transitional git clone of the svn repository
GC> # [GNU/Linux: 2 min; msw-xp: 41 min]
GC> git svn clone \
GC> file:///tmp/migration/repository \
GC> --authors-file=/tmp/migration/authors.txt \
GC> --prefix="origin/" --no-metadata --trunk=/ ./transitional
This normally ought to create HEAD pointing to master (you can run "git
symbolic-ref HEAD" or, if you're feeling particularly real-programmerishly[*],
just "cat .git/HEAD" to check this).
GC> # create new bare repository
GC> mkdir blessed
GC> pushd blessed
GC> git init --bare ./proprietary
GC> pushd proprietary
GC> git symbolic-ref HEAD refs/heads/trunk
GC> git rev-parse HEAD
GC> popd
GC> popd
This seems to be the part which creates problems later. Why do you do
this? AFAICS you should simply delete the last two git commands entirely,
just "git init" is all you need.
GC> # push to bare repository
GC> pushd /tmp/migration/transitional
GC> git remote add bare /tmp/migration/blessed/proprietary
GC> git config remote.bare.push 'refs/remotes/*:refs/heads/*'
GC> git push bare
GC> popd
This is also quite strange. Why do you configure git to push the local
remotes to remote heads (i.e. branches)? It kind of works because the only
remote you have here is the svn trunk which is, indeed, branch-like, but
this could result in something really strange happening in other
situations. I would just do "git push --all bare".
GC> # rename 'trunk' to 'master'
GC> pushd /tmp/migration/blessed/proprietary
GC> git branch -m origin/trunk master
GC> popd
This seems to only be needed because of the previous steps. If you didn't
set the HEAD to point to trunk originally and didn't push trunk itself but
only the branches with "--all", you would already have "master" here.
GC> # clone from bare repository
GC> mkdir --parents migrated
GC> pushd migrated
GC> git clone -b master file:///tmp/migration/blessed/proprietary
And then, finally, you wouldn't need this "-b master" neither.
Of course, all these remarks don't mean that you must redo the clone
because, even if you took a rather long and winding road to get to it, the
end result is still exactly the same. I'm only mentioning it in case you
plan to do other svn-to-git migrations in the future or just need to know
why did you need this "-b master" at the end.
Regards,
VZ
[*] https://xkcd.com/378/