Convert from Git Scenario
[DRAFT: this page is still being reviewed by bzr experts for correctness.]
Suppose you want to convert a repository maintained in Git to bzr. We'll assume you already have git installed. Here's an overview of how you'd do it:
- Install the bzr-fastimport plugin.
- Create a bzr repo to host the corresponding bzr branches
- Use git's fast-export to export a formatted version of the repository's history.
- Use bzr's fast-import plugin to import the formatted version to recreate the repository.
Assume that your git repository is in git-repo and you wish to make corresponding bzr branches for all git branches in a bzr repository at bzr-repo.
First we need to install bzr's fast-import plugin. This plugin is not shipped as part of the bzr installation. If you have not yet installed it, the following commands will fetch and install the latest version from its home on launchpad:
$ cd ~/.bazaar/plugins $ bzr branch lp:bzr-fastimport fastimport
You'll then need to create the bzr repository:
$ bzr init-repo bzr-repo
Then use git's fast-export to export all the branches, and use bzr's fast-import plugin to import and recreate the branches:
$ git fast-export -M --all | (cd bzr-repo; bzr fast-import -)
In the above, we used git fast-export's -M flag to embed git's inferred file-renames into the formatted output; you may wish to drop this.
Bzr's fast-import plugin periodically checkpoints its progress. If the import is interrupted or should crash, you can restart import and the plugin will skip over the already-loaded versions.
See bzr help fast-import for more information.
For large repositories, you may get better performance by allowing bzr's fast-import to do some initial pre-processing to generate some caching hints:
$ git fast-export -M --all > exported.fi $ bzr fast-import-info -v exported.fi > exported.cfg $ bzr fast-import exported.fi --info exported.cfg