Migrate a repository from bazaar to git
Read time: 1 min
Developers may have the need to change some tools they work with everyday, like VCS. This guide explains how to completely port a bazaar repository to a Git one.
Porting the repo is no more than few commands:
$ 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
Now verify that everything is there:
$ git log
You should see the commit history.
Double check using:
$ diff -r repo-dir repo-dir_backup
Do it before you delete the backup directory.
Migrate the ignore file
Migrate .bzrignore to .gitignore:
$ git mv .bzrignore .gitignore
Commit all the things
Commit the repository migration:
$ git commit -a -m "Migrated from Bazaar to Git."
Optional: Now, you can add a remote to your git repo.
If you get
ERROR: unknown command "fast-export"), type:
$ sudo apt-get install bzr-fastimport
to sort it out.
Thanks for reading.
Got some words you want to share? Tell me!