Here in the design team we use both Bazaar and Git to keep track our projects' hostory.

We quite often end up coverting our projects from Bazaar to Git or vice-versa. Here are some tips on how to do that.

Converting between Git and Bazaar

To convert revision history between Git and Bazaar, we will use their respective fast-import features.

Install bzr-fastimport

In either case, you need the fastimport plugin for Bazaar, which installs both bzr fast-import and bzr fast-export:

cd ~/.bazaar/plugins
bzr branch lp:bzr-fastimport fastimport

Git to Bazaar

To convert a Bazaar branch to Git, open a Bazaar branch of your project and do the following:

git init                                        # Initialise a new git repo
bzr fast-export --plain . | git fast-import     # Import Bazaar history into Git

Now you should have all the revision history for that Bazaar branch in Git:

git log  # Check your revision history is in Git

(From Astrofloyd's blog)

Bazaar to Git

Converting from Bazaar to Git is slightly different. Because Bazaar stores branches in sub-folders, while Git stores branches all in the same directory, when you convert a Git repository to Bazaar, it will create a directory tree for the branches:

bzr init-repo bzr-repo                                       # Create a new Bazaar repository tree
git fast-export -M --all | (cd bzr-repo; bzr fast-import -)  # Export Git history into Bazaar

bzr-repo will now contain a folder for each branch that was in your Git repository. You're probably most interested in trunk, which will be at bzr-repo/trunk, or perhaps bzr-repo/trunk.remote:

cd bzr-repo/trunk  # Open the "trunk" branch (equivalent of "master")
bzr log | less     # Check your revision history is in Bazaar

(From the Bazaar wiki)

Keeping a project in both Git and Bazaar

You may wish to keep a project in both Git and Bazaar.

Create ignore files for both systems

As your project may be used in either Git or Bazaar, you should create practically duplicate .gitignore and .bzrignore files, the only difference being that the .bzrignore should ignore the .git directory, and the .gitignore should ignore the .bzr directory. You should also make sure you ignore the bzr-repo directory - e.g.:

$ cat .gitignore
.bzr/
.sass-cache/
bzr-repo/
*.pyc
$ cat .bzrignore
.git/
.sass-cache/
bzr-repo/
*.pyc

And keep both ignore files in all versions of the project.

Only work in one repository

It is not practical to be doing your actual work in both systems, because converting from one to the other will overwrite any history in the destination repository. For this reason you need to choose to do all your work in either Git or Bazaar, and then regularly convert it to the other using the above conversion instructions.

(Originally published on design.canonical.com)