Mirroring Bazaar repository into Git on a Mac

Greg Dubicki
2 min readFeb 9, 2020
Bazaar logo has been copied from http://wiki.bazaar.canonical.com/LogoOptions, copyright and trademark Canonical Ltd. Git logo has been copied from https://git-scm.com/downloads/logos and has been created by Jason Long and is licensed under the Creative Commons Attribution 3.0 Unported License.

This article is based on “Mirroring Bazaar Repositories with Git” article written by Nick Charlton in 2015 (thank you!), updated for 2020 and focused solely on using a Mac with Homebrew.

Introduction

I want to create a version of Ubuntu/Debian’s update-motd for other distros, in particular for RedHat/Centos 7 used at my company.

(Why and how is a topic for another article, please follow me if you are interested in that!)

I found the source repository with the package that provided this feature in Launchpad here, but as it’s an Ubuntu package, it is hosted on Launchpad using Bazaar.

I wanted to keep the history of the code but also to work using Git and on GitHub, so I had to do a conversion.

How-to

1. Install bazaar and a plugin to make it work with git

brew install bazaar

bzr-git is the git plugin for Bazaar. I provide a custom brew formula for it as a tap you. You can check the code of this formula here.

brew tap gdubicki/tap
brew install gdubicki/tap/bzr-git

2. Clone the Bazaar repository

I got below command directly from the update-motd Launchpad page, top-left corner. It creates a local branch of the project from Launchpad (‘lp’), branch ‘update-motd’.

bzr branch lp:update-motd

3. Create the Git repository

You can create it where ever you usually create your hosted repositories — GitHub, GitLab… But DO NOT initialize the repo with anything (like adding a README).

All you’ll need is the URL to the repo, in my case:

git+ssh://git@github.com/gdubicki/update-motd-for-non-ubuntu.git

Yes, you NEED to use git+sshas protocol.

4. Push the clone to the remote

The final step is to push you Bazaar branch to Git repository:

cd update-motd # or whatever is the name of the Bazaar repo/branchPYTHONPATH="/usr/local/lib/python2.7/site-packages" bzr dpush -v git+ssh://git@github.com/gdubicki/update-motd-for-non-ubuntu.git,branch=master

(The reason for having to use this custom PYTHONPATH is that Homebrew’s Bazaar and its bzr-git plugin are using macOS system Python 2.7, but most probably your default one nowadays is Python 3 from Homebrew.)

You should now have a full copy of all of the original bazaar history, but now all configured with git.

Legal

The original article is available under CC BY-NC-SA 2.0. This article is available under the same license.

--

--