The Allegro Wiki is undergoing maintenance, please be patient.


From Allegro Wiki
Jump to: navigation, search

The easy way

Converting a copy of the SVN repository to git takes a long time. Luckily for you, I've already done it. You can download it from

The authors.txt file it maps SVN usernames to author names. Everyone who has committed needs to be listed (so you might need to add to it occasionally). Don't worry about the phony email addresses.

   % tar jxf allegro-git-20090117.tar.bz2
   % cd allegro.git
   % git config svn.authorsfile /path/to/authors.txt
   % git checkout -f

Now you can do your first update:

   % git svn rebase

For interest's sake, instructions for converting the repository yourself are at the end of this message.

Using git-svn


Do your work in this workspace, making local commits with git. I think the git-svn documentation suggests you leave the 'master' branch containing only the public changes from SVN, so do your work in another branch:

   % git checkout -b myfeature
   # hack hack hack
   % git commit -a

You can see all the branches and tags with:

   % git branch -r 

Updating from SVN

First make sure there are no uncommitted changes, then run:

   % git svn rebase

Your local changes on the current branch will be put on top of the public changes. You can also download and rebase separately, which is useful for rebasing multiple local branches.

   % git svn fetch
   % git svn rebase -l

If you do have uncommitted changes lying around, you can either make a temporary commit, which you undo later, or use the `git stash` feature. I usually do the former as I forget about things I've stashed. Undoing the top commit is simple:

   % git reset HEAD~1

Publishing changes

You can publish your local changes to SVN with:

   % git svn dcommit

I usually run `git svn dcommit -n` first just to check it's the expected number of changes. `git log` will tell you what the changes are.

Don't feel like you have to publish every local change immediately. If you leave it for a while you'll probably think of something that you forgot. Then you can amend the change locally, saving yourself some embarrassment (and keeping our SVN history a bit cleaner).

SourceForge's servers aren't the fastest, so it's nice to batch up changes then let `dcommit` be patient while you do something else.

Cloning the repository

Normally you'd use `git clone` to make a copy of a repository, but unfortunately that won't keep the metadata required for `git-svn`. Just make a plain copy, say, using rsync.

Finally, if you're new to `git`, here are some of my favourite commands which you won't find in `svn` (at least, easily):

  • git commit --amend
  • git rebase -i
  • git diff --color-words
  • git grep
  • git show
  • git log -p
  • git add -p

Converting the repository

This is not strictly necessary, but I recommend mirroring the SVN repository to the local disk before attempting a conversion. If something goes wrong you won't have to download everything from SourceForge again. The repository is more than 170 MB.

   % SVN_MIRROR=/path_to_store_at/alleg
   % mkdir -p $SVN_MIRROR
   % rsync -c -av'*' $SVN_MIRROR

Now the actual conversion:

   % mkdir myworkspace
   % cd myworkspace
   % git svn init file://$SVN_MIRROR/allegro \
       --rewrite-root= \
       --trunk=trunk --branches=branches --tags=tags
   % git config svn.authorsfile /path/to/authors.txt
   % git svn fetch

The last step takes a long time. Once it's done, just for kicks, check the size of the git repository. Remember what it was before?

   % du -sh .git
   25M .git