|
| 1 | +==== Bazaar |
| 2 | +(((Bazaar)))(((Importing, from Bazaar))) |
| 3 | + |
| 4 | +Bazaar is a distributed source management content like Git. |
| 5 | +It is very easy to convert a Bazaar repository into a Git repository thanks to Bazaar's plugin system. |
| 6 | +To convert a Bazaar repository into a Git repository, you have first to import the bzr-fastimport plugin. |
| 7 | +Here is the whole procedure if you have not yet imported any plugin: |
| 8 | +[source,console] |
| 9 | +---- |
| 10 | +$ mkdir --parents ~/.bazaar/plugins/bzr # creates the necessary folders for the plugins |
| 11 | +$ cd ~/.bazaar/plugins/bzr |
| 12 | +$ bzr branch lp:bzr-fastimport fastimport # imports the fastimport plugin |
| 13 | +$ cd fastimport |
| 14 | +$ sudo python setup.py install --record=files.txt |
| 15 | +---- |
| 16 | + |
| 17 | +There you go! |
| 18 | +You've just installed the fastimport plugin. |
| 19 | + |
| 20 | + |
| 21 | +===== Case of a project with a single branch |
| 22 | + |
| 23 | +Now go in the directory that contains your Bazaar repository and initialize the Git repository: |
| 24 | +[source,console] |
| 25 | +---- |
| 26 | +$ cd path/to/the/bzr/repository |
| 27 | +$ git init |
| 28 | +---- |
| 29 | + |
| 30 | +Now, you can simply export your Bazaar repository and convert it into a Git repository using the following command: |
| 31 | +[source,console] |
| 32 | +---- |
| 33 | +$ bzr fast-export --plain . | git fast-import |
| 34 | +---- |
| 35 | + |
| 36 | +You may get the following error message: |
| 37 | +[source,console] |
| 38 | +---- |
| 39 | +bzr: ERROR: Unable to import library "fastimport": bzr-fastimport requires the fastimport python module |
| 40 | +---- |
| 41 | + |
| 42 | +This message is displayed because the fastimport python module that the `bzr fast-export` command needs is missing. |
| 43 | +Install it from your package manager if you are under GNU/Linux or download it at address https://pypi.python.org/pypi/fastimport/[] if you are under Windows. |
| 44 | +For example, with Fedora, you would do the following: |
| 45 | + |
| 46 | +[source,console] |
| 47 | +---- |
| 48 | +$ sudo dnf install python-fastimport |
| 49 | +---- |
| 50 | + |
| 51 | +Now you can export your Bazaar repository to the Git repository. |
| 52 | + |
| 53 | +Depending on the size of the project, your Git repository is built in a lapse from a few seconds to a few minutes. |
| 54 | + |
| 55 | +At this point, if you type `git status`, you'll see that the tracked files are now marked as removed for the next commit. |
| 56 | +Here is an example: |
| 57 | +[source,console] |
| 58 | +---- |
| 59 | +$ git status |
| 60 | +On master branch |
| 61 | +Changes that will be validated: |
| 62 | + (use "git reset HEAD <fichier>..." to unstage) |
| 63 | +
|
| 64 | + removed : .bzrignore |
| 65 | + removed : file.txt |
| 66 | +
|
| 67 | +Untracked files: |
| 68 | + (use "git add <fichier>..." to include in what will be validated) |
| 69 | +
|
| 70 | + .bzr/ |
| 71 | + .bzrignore |
| 72 | + file.txt |
| 73 | +---- |
| 74 | + |
| 75 | +You can restore the repository in a correct state very simply with the `git reset` command: |
| 76 | +[source,console] |
| 77 | +---- |
| 78 | +$ git reset HEAD . |
| 79 | +---- |
| 80 | + |
| 81 | +Now let us have a look at the files to ignore. |
| 82 | +As .bzrignore's format is completely compatible with .gitignore's format, the simplest is to rename your .bzrignore file: |
| 83 | +[source,console] |
| 84 | +---- |
| 85 | +$ git mv .bzrignore .gitignore |
| 86 | +---- |
| 87 | + |
| 88 | +Let us check your repository's status: |
| 89 | +[source,console] |
| 90 | +---- |
| 91 | +$ git status |
| 92 | +On master branch |
| 93 | +Changes that will be validated : |
| 94 | + (use "git reset HEAD <fichier>..." to unstage) |
| 95 | +
|
| 96 | + renamed : .bzrignore -> .gitignore |
| 97 | +
|
| 98 | +Untracked files: |
| 99 | + (use "git add <fichier>..." to include in what will be validated) |
| 100 | +
|
| 101 | + .bzr/ |
| 102 | +
|
| 103 | +---- |
| 104 | + |
| 105 | +Then you have to create a commit that contains those changes for the migration: |
| 106 | +[source,console] |
| 107 | +---- |
| 108 | +$ git commit -am 'Migration from Bazaar to Git' |
| 109 | +---- |
| 110 | + |
| 111 | +That's all! |
| 112 | +Now you can push the repository onto its new home server: |
| 113 | +[source,console] |
| 114 | +---- |
| 115 | +$ git remote add origin git@my-git-server:mygitrepository.git |
| 116 | +$ git push origin --all |
| 117 | +$ git push origin --tags |
| 118 | +---- |
| 119 | + |
| 120 | +===== Case of a project with a main branch and a working branch |
| 121 | + |
| 122 | +You can also import a Bazaar repository that contains branches. |
| 123 | +Let us suppose that you have two branches: one represents the main branch (myProject.trunk), the other one is the working branch (myProject.work). |
| 124 | +[source,console] |
| 125 | +---- |
| 126 | +$ ls |
| 127 | +myProject.trunk myProject.work |
| 128 | +---- |
| 129 | + |
| 130 | +Create the Git repository and go into it: |
| 131 | +[source,console] |
| 132 | +---- |
| 133 | +$ git init git-repo |
| 134 | +$ cd git-repo |
| 135 | +---- |
| 136 | + |
| 137 | +Pull the master branch into git: |
| 138 | +[source,console] |
| 139 | +---- |
| 140 | +$ bzr fast-export --export-marks=../marks.bzr ../myProject.trunk | \ |
| 141 | +git fast-import --export-marks=../marks.git |
| 142 | +---- |
| 143 | + |
| 144 | +Pull the working branch into Git: |
| 145 | +[source,console] |
| 146 | +---- |
| 147 | +$ bzr fast-export --marks=../marks.bzr --git-branch=work ../myProject.work | \ |
| 148 | +git fast-import --import-marks=../marks.git --export-marks=../marks.git |
| 149 | +---- |
| 150 | + |
| 151 | +Now `git branch` shows you the `master` branch as well as the `work` branch. |
| 152 | +Check the logs to make sure they’re complete and get rid of the `marks.bzr` and `marks.git` files. |
| 153 | + |
| 154 | +Your Git repository is ready to use. |
0 commit comments