A hot topic this past DebConf7 was
git. I've bought into the hype, so I decided to take the plunge and move my
Subversion repositories to it. A lot of people seem to be willing to part with their history when making the move, but I'm some what irrationally attached to it.
Most of my Debian packages are in one big SVN repo, which used to be one big CVS repo (I used cvs2svn to move). So I decided to pull apart each source package into its own git repository. I started with git svn clone like so:
$ git svn clone -A authors --trunk=trunk/libclass-makemethods-perl \
--branches=branches/libclass-makemethods-perl/upstream \
--tags=tags/libclass-makemethods-perl --no-metadata \
file:///home/svn/debian libclass-makemethods-perl
And this gives a git repo that can track an SVN repo. But I want to go all the way, no turning back. So I made a little script to clean up this repo called
clean-git-svn
:
#!/bin/sh -e
tags= git branch -r egrep 'tags/[^@]+$'
echo "$tags" perl -ne \
'chomp($_); my $head = $_; s,\s+tags,debian,g; print "git tag $_ $head^\n"'
for i in $tags ; do echo "git branch -r -d $i"; done
upstream_tags= git branch -r egrep ' +[0-9][^@]+$'
echo "$upstream_tags" perl -ne \
'chomp($_); s,\s+,,g; print "git tag upstream/$_ $_^\n"'
for i in $upstream_tags ; do echo "git branch -r -d $i"; done
echo "git branch upstream current"
echo "git branch -r -d current"
echo "git branch -r -d trunk"
This will output a bunch of git commands that will make this a more "gitified" repo. I make no guarantees this will work, you should probably hand check your history with
gitk
to make sure this won't screw anything up. If your the part you're converting also came up from CVS, you'll probably have a bit of a mess on your hands that will need more manual cleanup.
gitk
is really an amazing visualization tool and can help a lot here. Once you're satisfied just pipe it into
/bin/sh
. Since git svn mostly can't track where you merged in your SVN repo, make sure you merge the
upstream
branch into
master
as soon as you can. It will save you a lot of conflicts later, trust me.
One thing I miss from
svn
is
svn export
. Does an equivalent command exist in git? You would think there would be an option you could pass to
git clone
to do this but I can't seem to find anything.