Skip to content

Commit 2f449a3

Browse files
committed
corrections done as per J.N. Avila's suggestions
1 parent d1fb00d commit 2f449a3

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

book/09-git-and-other-scms/sections/import-bzr.asc

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,34 @@
44
Bazaar is a DVCS tool much like Git, and as a result it's pretty straightforward to convert a Bazaar repository into a Git one.
55
To accomplish this, you'll need to import the `bzr-fastimport` plugin.
66

7-
87
===== Getting the bzr-fastimport plugin
98

109
The procedure for installing the fastimport plugin is different on UNIX-like operating systems and on Windows.
1110
In the first case, the simplest is to install the `bzr-fastimport` package that will install all the required dependencies.
1211

1312
For example, with Debian and derived, you would do the following:
13+
1414
[source,console]
1515
----
1616
$ sudo apt-get install bzr-fastimport
1717
----
1818

1919
With RHEL, you would do the following:
20+
2021
[source,console]
2122
----
2223
$ sudo yum install bzr-fast-import
2324
----
2425

2526
With Fedora, since release 22, the new package manager is dnf:
27+
2628
[source,console]
2729
----
2830
$ sudo dnf install bzr-fastimport
2931
----
3032

3133
If the package is not available, you may install it as a plugin:
34+
3235
[source,console]
3336
----
3437
$ mkdir --parents ~/.bazaar/plugins/bzr # creates the necessary folders for the plugins
@@ -40,6 +43,7 @@ $ sudo python setup.py install --record=files.txt # installs the plugin
4043

4144
For this plugin to work, you'll also need the `fastimport` Python module.
4245
You can check whether it is present or not and install it with the following commands:
46+
4347
[source,console]
4448
----
4549
$ python -c "import fastimport"
@@ -55,50 +59,54 @@ So in this case you have nothing to do.
5559

5660
At this point, the way to import a Bazaar repository differs according to that you have a single branch or you are working with a repository that has several branches.
5761

58-
5962
===== Project with a single branch
6063

6164
Now `cd` in the directory that contains your Bazaar repository and initialize the Git repository:
65+
6266
[source,console]
6367
----
6468
$ cd /path/to/the/bzr/repository
6569
$ git init
6670
----
6771

6872
Now, you can simply export your Bazaar repository and convert it into a Git repository using the following command:
73+
6974
[source,console]
7075
----
7176
$ bzr fast-export --plain . | git fast-import
7277
----
7378

7479
Depending on the size of the project, your Git repository is built in a lapse from a few seconds to a few minutes.
7580

76-
7781
===== Case of a project with a main branch and a working branch
7882

7983
You can also import a Bazaar repository that contains branches.
8084
Let us suppose that you have two branches: one represents the main branch (myProject.trunk), the other one is the working branch (myProject.work).
85+
8186
[source,console]
8287
----
8388
$ ls
8489
myProject.trunk myProject.work
8590
----
8691

8792
Create the Git repository and `cd` into it:
93+
8894
[source,console]
8995
----
9096
$ git init git-repo
9197
$ cd git-repo
9298
----
9399

94100
Pull the master branch into git:
101+
95102
[source,console]
96103
----
97104
$ bzr fast-export --export-marks=../marks.bzr ../myProject.trunk | \
98105
git fast-import --export-marks=../marks.git
99106
----
100107

101108
Pull the working branch into Git:
109+
102110
[source,console]
103111
----
104112
$ bzr fast-export --marks=../marks.bzr --git-branch=work ../myProject.work | \
@@ -108,33 +116,33 @@ git fast-import --import-marks=../marks.git --export-marks=../marks.git
108116
Now `git branch` shows you the `master` branch as well as the `work` branch.
109117
Check the logs to make sure they’re complete and get rid of the `marks.bzr` and `marks.git` files.
110118

119+
===== Synchronizing the staging area
111120

112-
===== Synchronize the staging area
113-
114-
Whatever the number of branches you had and the import method you used, your staging area is not synchronized with HEAD, and with the import of several branches, your working directory is not synchronized neither.
121+
Whatever the number of branches you had and the import method you used, your staging area is not synchronized with `HEAD`, and with the import of several branches, your working directory is not synchronized either.
115122
This situation is easily solved by the following command:
123+
116124
[source,console]
117125
----
118126
$ git reset --hard HEAD
119127
----
120128

129+
===== Ignoring the files that were ignored with .bzrignore
121130

122-
===== Ignore the files that were ignored with .bzrignore
123-
124-
Now let us have a look at the files to ignore.
131+
Now let's have a look at the files to ignore.
125132
As `.bzrignore`'s format is completely compatible with `.gitignore`'s format, the simplest is to rename your `.bzrignore` file.
126133
You will also have to create a commit that contains this change for the migration:
134+
127135
[source,console]
128136
----
129137
$ git mv .bzrignore .gitignore
130138
$ git commit -am 'Migration from Bazaar to Git'
131139
----
132140

133-
134141
===== Send your repository to the server
135142

136143
Here we are!
137144
Now you can push the repository onto its new home server:
145+
138146
[source,console]
139147
----
140148
$ git remote add origin git@my-git-server:mygitrepository.git

0 commit comments

Comments
 (0)