Convert bzr to git

I played with bzr (Bazaar) as a source-control manager (SCM) for a while, after having used svn for a couple of years. In the end, bzr turned out to be the stepping stone I needed to move to git. Hence, I started converting my repositories from bzr to git. Here’s how it’s easily done.

For this method, you’ll need to install the package bzr-fastimport to export data from your bzr repository. Gentoo users emerge dev-vcs/bzr-fastimport. Before you start, make sure you committed all your changes, e.g. using bzr st and bzr diff.

Then:

  cp -pr repo-dir repo-dir_backup                 # Make a backup
  cd repo-dir                                     # Change into your dir
  git init                                        # Initialise a new git repo
  bzr fast-export --plain . | git fast-import     # Do the actual conversion
  git co -f master                                # Will reply 'Already on master'
  rm -rf .bzr/                                    # Remove the bzr data

Verify that everything is there (e.g. using diff -r repo-dir repo-dir_backup) before you delete the backup directory. You’re all set.

This entry was posted in All, Software and tagged , , . Bookmark the permalink.

6 Responses to Convert bzr to git

  1. Michael Rooney says:

    Thanks so much, this was a breeze! I had needed to do this last year before you wrote this, and went through three much more difficult methods, and was not looking forward to it, so this was a relief 🙂

  2. Great Information!
    Its very useful

  3. Alex Eiser says:

    This is a great post, but I wanted to also point you at this one

    http://blog.timmattison.com/archives/2011/06/13/how-to-convert-from-bzr-to-git-on-debianubuntu/

    Which documents how to import multiple branches. Basically it notes you can use the –export-marks / –import-marks and –git-branch= flags to add multiple related branches.

  4. Pingback: Convert bzr to git – Benjamin Oakes

  5. Pingback: Canonical Design Team: Converting projects between Git and Bazaar | Hi-tech news

  6. Daniel Kulesz says:

    Great tutorial, however, does not work with newer Distributions anymore. But it works like a charm using a Debian-Wheezy chroot, except that you have to call “git checkout” instead of “git co” as the git version there is rather old.

Leave a comment