Home

apparently I'm a dinosaur

git'ing it on

the dinosaur

floating

git'ing it on

Previous Entry Add to Memories Tell a Friend Next Entry
floating
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.
  • git archive --format=tar --prefix=whatever/ HEAD

    (Anonymous)
    That'll dump a tar file of the current HEAD to stdout. Replace whatever/ with the top-level prefix for the contents. Replace HEAD with whatever tree-ish reference you want to dump. And use --format=zip for zip.

    I don't know off-hand if it works for remote git repos. If you just want a shallow clone (no history), use git clone --depth 1. There's often not much point because git repos compress really, really well.
  • svn export equivalent

    (Anonymous)
    It depends on what you want to do. If you want to create a tarball, you can do that with git archive. In general, you can create an export by piping the output of git archive into tar, or by nuking the .git directory from a copy that you create with git clone. There might be a more elegant way, but I haven't found it.
  • svn export

    (Anonymous)
    You can also try this:
    cd /export/dir
    GIT_DIR=/git/dir/.git git checkout -f

    glandium
  • git-pack-refs

    Check out Sam's suggestion for mass ref-editing: http://lists.madduck.net/pipermail/vcs-pkg/2007-October/000057.html
  • (no subject) - [info]dennisdman Expand
Powered by LiveJournal.com