You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
===== Create a Git repository from a Bazaar repository
17
23
18
24
It is simple to use.
19
25
It is enough to clone a Bazaar repository prefixing it by `bzr::`.
20
-
If you worked in a local Bazaar repository and pushed to a remote one, it is better to clone the remote.
21
-
That will make your work simpler; else you must go through your local repository and you may have problems when pushing to the remote if your Bazaar and Git repositories were not up-to-date.
26
+
Since Git and Bazaar both do full clones to your machine, it's possible to attach a Git clone to your local Bazaar clone, but it isn't recommended.
27
+
It's much easier to attach your Git clone directly to the same place your Bazaar clone is attached to ‒ the central repository.
22
28
23
29
Let's suppose that you worked with a remote repository which is at address `bzr+ssh://developer@mybazaarserver:myproject`.
As the format of the .bzrignore file is completely compatible with .gitignore's one, and as you shouldn't make a .gitignore file in your repository, it is enough to make a symbolic link to .bzrignore so that the potential changes of .bzrignore are taken into account:
77
+
As the format of the `.bzrignore` file is completely compatible with `.gitignore`'s one, and as you shouldn't make a `.gitignore` file in your repository, it is enough to make a symbolic link to `.bzrignore` so that the potential changes of `.bzrignore` are taken into account:
71
78
[source,console]
72
79
----
73
80
$ ln -s .bzrignore .git/info/exclude
@@ -84,6 +91,8 @@ $ git pull --rebase origin
84
91
85
92
===== Push your work on the remote repository
86
93
94
+
Because Bazaar supports very well merge commits, there will be no problem if you push a merge commit.
95
+
So you can work on a branch, merge the changes into `master` and push your work.
87
96
Then, you create your branches, you test and commit your work as usual.
88
97
You finally push your work to the Bazaar repository:
89
98
[source,console]
@@ -93,10 +102,13 @@ $ git push origin master
93
102
94
103
===== Caveats
95
104
96
-
There are some limitations while pushing to a Bazaar repository.
97
-
Please refer to the README file of the project's Git repository (https://github.com/felipec/git-remote-bzr[]) for more information about this.
105
+
Limitations of the remote-helpers' framework apply. In particular, these commands don't work:
106
+
107
+
* git push origin :branch-to-delete (Bazaar can't accept ref deletions in this way.)
108
+
* git push origin old:new (it will push 'old')
109
+
* git push --dry-run origin branch (it will push)
98
110
99
111
===== Summary
100
112
101
-
As Git and Bazaarare close, you can work in a Git repository and transparently push your work to a Bazaar repository.
102
-
Be careful anyway to the limitations.
113
+
Since Git's and Bazaar's models are similar, there isn't a lot of resistance when working across the boundary.
114
+
As long as you watch out for the limitations, and are always aware that the remote repository isn't natively Git, you'll be fine.
Copy file name to clipboardExpand all lines: book/09-git-and-other-scms/sections/import-bzr.asc
+51-50Lines changed: 51 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,59 +1,78 @@
1
1
==== Bazaar
2
2
(((Bazaar)))(((Importing, from Bazaar)))
3
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:
4
+
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.
5
+
To accomplish this, you'll need to import the `bzr-fastimport` plugin.
6
+
7
+
8
+
===== Getting the bzr-fastimport plugin
9
+
10
+
According to you are using a UNIX-like operating system or Windows, the procedure differs.
11
+
If you are using a UNIX-like operating system, the simplest is to install the `bzr-fastimport` package that will install all the required dependencies.
12
+
13
+
For example, with Debian and derived, you would do the following:
8
14
[source,console]
9
15
----
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
16
+
$ sudo apt-get install bzr-fastimport
15
17
----
16
18
17
-
There you go!
18
-
You've just installed the fastimport plugin.
19
-
20
-
21
-
===== Case of a project with a single branch
19
+
With RHEL, you would do the following:
20
+
[source,console]
21
+
----
22
+
$ sudo yum install bzr-fast-import
23
+
----
22
24
23
-
Now go in the directory that contains your Bazaar repository and initialize the Git repository:
25
+
With Fedora, since release 22, the new package manager is dnf:
24
26
[source,console]
25
27
----
26
-
$ cd path/to/the/bzr/repository
27
-
$ git init
28
+
$ sudo dnf install bzr-fastimport
28
29
----
29
30
30
-
Now, you can simply export your Bazaar repository and convert it into a Git repository using the following command:
31
+
If the package is not available, you may install it as a plugin:
31
32
[source,console]
32
33
----
33
-
$ bzr fast-export --plain . | git fast-import
34
+
$ mkdir --parents ~/.bazaar/plugins/bzr # creates the necessary folders for the plugins
35
+
$ cd ~/.bazaar/plugins/bzr
36
+
$ bzr branch lp:bzr-fastimport fastimport # imports the fastimport plugin
37
+
$ cd fastimport
38
+
$ sudo python setup.py install --record=files.txt # installs the plugin
34
39
----
35
40
36
-
You may get the following error message:
41
+
For this plugin to work, you'll also need the `fastimport` Python module.
42
+
You can check whether it is present or not and install it with the following commands:
37
43
[source,console]
38
44
----
39
-
bzr: ERROR: Unable to import library "fastimport": bzr-fastimport requires the fastimport python module
45
+
$ python -c "import fastimport"
46
+
Traceback (most recent call last):
47
+
File "<string>", line 1, in <module>
48
+
ImportError: No module named fastimport
49
+
$ pip install fastimport
40
50
----
51
+
If it is not available, you can download it at address https://pypi.python.org/pypi/fastimport/.
52
+
53
+
With Windows, `bzr-fastimport` is automatically installed with the standalone version and the default installation (let all the checkboxes checked).
54
+
So in this case you have nothing to do.
41
55
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:
56
+
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.
45
57
58
+
===== Case of a project with a single branch
59
+
60
+
Now `cd` in the directory that contains your Bazaar repository and initialize the Git repository:
46
61
[source,console]
47
62
----
48
-
$ sudo dnf install python-fastimport
63
+
$ cd /path/to/the/bzr/repository
64
+
$ git init
49
65
----
50
66
51
-
Now you can export your Bazaar repository to the Git repository.
67
+
Now, you can simply export your Bazaar repository and convert it into a Git repository using the following command:
68
+
[source,console]
69
+
----
70
+
$ bzr fast-export --plain . | git fast-import
71
+
----
52
72
53
73
Depending on the size of the project, your Git repository is built in a lapse from a few seconds to a few minutes.
54
74
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:
75
+
At this point, the `.git` directory and your working tree are all set up, but Git's index isn't synchronised with the working tree:
57
76
[source,console]
58
77
----
59
78
$ git status
@@ -71,38 +90,20 @@ Untracked files:
71
90
.bzrignore
72
91
file.txt
73
92
----
74
-
75
-
You can restore the repository in a correct state very simply with the `git reset` command:
93
+
Type this to fix that:
76
94
[source,console]
77
95
----
78
96
$ git reset HEAD .
79
97
----
80
98
81
99
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:
100
+
As `.bzrignore`'s format is completely compatible with `.gitignore`'s format, the simplest is to rename your `.bzrignore` file:
83
101
[source,console]
84
102
----
85
103
$ git mv .bzrignore .gitignore
86
104
----
87
105
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
+
Then you have to create a commit that contains this change for the migration:
0 commit comments