|
| 1 | +==== Git and Bazaar |
| 2 | + |
| 3 | +There are many projects that allow you to use Git as a Bazaar client. |
| 4 | +Here we'll use Felipe Contreras' project that you may find at https://github.com/felipec/git-remote-bzr[]. |
| 5 | +To install it, you just have to download the file git-remote-bzr in a folder contained in your `$PATH`: |
| 6 | +[source,console] |
| 7 | +---- |
| 8 | +$ wget https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr -O ~/bin/git-remote-bzr |
| 9 | +$ chmod +x ~/bin/git-remote-bzr |
| 10 | +---- |
| 11 | + |
| 12 | +You also need to have Bazaar installed. |
| 13 | + |
| 14 | +That's all! |
| 15 | + |
| 16 | +===== Create a Git repository from a Bazaar repository |
| 17 | + |
| 18 | +It is simple to use. |
| 19 | +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. |
| 22 | + |
| 23 | +Let's suppose that you worked with a remote repository which is at address `bzr+ssh://developer@mybazaarserver:myproject`. |
| 24 | +Then you must clone it in the following way: |
| 25 | +[source,console] |
| 26 | +---- |
| 27 | +$ git clone bzr::bzr+ssh://developer@mybazaarserver:myproject myProject-Git |
| 28 | +$ cd myProject-Git |
| 29 | +---- |
| 30 | + |
| 31 | +You should also clean and compact the created Git repository, especially if it is a big one: |
| 32 | +[source,console] |
| 33 | +---- |
| 34 | +$ git gc --aggressive |
| 35 | +---- |
| 36 | + |
| 37 | +===== Bazaar branches |
| 38 | + |
| 39 | +Bazaar only allows you to clone branches, but a repository may contain several branches, and `git-remote-bzr` can clone both. |
| 40 | +For example, to clone a branch: |
| 41 | +[source,console] |
| 42 | +---- |
| 43 | +$ git config remote-bzr.branches 'trunk, xwindow' |
| 44 | +---- |
| 45 | + |
| 46 | +And to clone the whole repository: |
| 47 | +[source,console] |
| 48 | +---- |
| 49 | +$ git clone bzr::bzr://bzr.savannah.gnu.org/emacs emacs |
| 50 | +---- |
| 51 | + |
| 52 | +The second command clones all the branches contained in the emacs repository; nevertheless, it is possible to point out some branches: |
| 53 | +[source,console] |
| 54 | +---- |
| 55 | +$ git config remote-bzr.branches 'trunk, xwindow' |
| 56 | +---- |
| 57 | + |
| 58 | +Some remote repositories don't allow to list their branches, in which case you have to manually specify them, and even though you could specify the configuration in the cloning command, you may find this easier: |
| 59 | + |
| 60 | +[source,console] |
| 61 | +---- |
| 62 | +$ git init emacs |
| 63 | +$ git remote add origin bzr::bzr://bzr.savannah.gnu.org/emacs |
| 64 | +$ git config remote-bzr.branches 'trunk, xwindow' |
| 65 | +$ git fetch |
| 66 | +---- |
| 67 | + |
| 68 | +===== Ignore what is ignored with .bzrignore |
| 69 | + |
| 70 | +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 | +[source,console] |
| 72 | +---- |
| 73 | +$ ln -s .bzrignore .git/info/exclude |
| 74 | +---- |
| 75 | + |
| 76 | +===== Fetch the changes of the remote repository |
| 77 | + |
| 78 | +To fetch the changes of the remote, you pull changes as usually, using Git commands. |
| 79 | +Supposing that your changes are on the `master` branch, you merge or rebase your work on the `origin/master` branch: |
| 80 | +[source,console] |
| 81 | +---- |
| 82 | +$ git pull --rebase origin |
| 83 | +---- |
| 84 | + |
| 85 | +===== Push your work on the remote repository |
| 86 | + |
| 87 | +Then, you create your branches, you test and commit your work as usual. |
| 88 | +You finally push your work to the Bazaar repository: |
| 89 | +[source,console] |
| 90 | +---- |
| 91 | +$ git push origin master |
| 92 | +---- |
| 93 | + |
| 94 | +===== Caveats |
| 95 | + |
| 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. |
| 98 | + |
| 99 | +===== Summary |
| 100 | + |
| 101 | +As Git and Bazaar are close, you can work in a Git repository and transparently push your work to a Bazaar repository. |
| 102 | +Be careful anyway to the limitations. |
0 commit comments