Onder de DVCSsen, is een andere beroemde: Bazaar. Bazaar is gratis en open source, en het is onderdeel van het GNU Project. Het gedraagt zich heel anders dan Git. Soms, om hetzelfde te bereiken als met Git, gebruik je een ander keyword, en sommige keywords die overeenkomen hebben niet dezelfde betekenis. In het bijzonder, is het beheren van branches erg anders en kan verwarring scheppen, in het bijzonder wanneer iemand uit het Git universum komt. Niettemin is het mogelijk om op een Bazaar repository te werken vanuit een Git omgeving.
Er zijn veel projecten die toestaan om een Git te gebruiken als een Bazaar client.
Hier zullen we het project van Felipe Contreras gebruiken die je kunt vinden op https://github.com/felipec/git-remote-bzr.
Om het te installeren, hoef je alleen het bestand git-remote-bzr in een folder te downloaden die in je $PATH
staat:
$ wget https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr -O ~/bin/git-remote-bzr
$ chmod +x ~/bin/git-remote-bzr
Je zult ooko Bazaar geinstalleerd moeten hebben. Dat is alles!
Het is eenvoudig in gebruik.
Het is voldoende om een Bazaar repository te klonen door het vooraf te laten gaan bzr::
.
Omdat Git en Bazaar beide een volledige kloon doen naar je machine, is het mogelijk om een Git kloon aan je lokale Bazaar kloon te knopen, maar dat wordt niet aangeraden.
Het is veel eenvoudiger om je Git kloon direct aan dezelfde plaats te knopen als waar je Bazaar kloon aan verbonden is - de centrale repository.
Laten we er vanuit gaan dat je gewerkt heb met een remote repository die staat op het adres bzr+ssh://developer@mybazaarserver:myproject
.
Dan moet je het op de volgende manier klonen:
$ git clone bzr::bzr+ssh://developer@mybazaarserver:myproject myProject-Git
$ cd myProject-Git
Nu is je Git repository gemaakt, maar het is nog niet geoptimaliseerd voor schijf gebruik. Dat is waarom je ook je Git repository moet schoonmaken en optimaliseren, zeker als het een grote is:
$ git gc --aggressive
Bazaar staat alleen toe om branches te klonen, maar een repository kan verscheidene branches bevatten, en git-remote-bzr
kan beide klonen.
Bijvoorbeeld: om een branch te klonen:
$ git clone bzr::bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk
En om de gehele repository te klonen:
$ git clone bzr::bzr://bzr.savannah.gnu.org/emacs emacs
The second command clones all the branches contained in the emacs repository; nevertheless, it is possible to point out some branches:
$ git config remote-bzr.branches 'trunk, xwindow'
Some remote repositories don’t allow you 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:
$ git init emacs
$ git remote add origin bzr::bzr://bzr.savannah.gnu.org/emacs
$ git config remote-bzr.branches 'trunk, xwindow'
$ git fetch
Since you are working on a project managed with Bazaar, you shouldn’t create a .gitignore
file because you may accidentally set it under version control and the other people working with Bazaar would be disturbed.
The solution is to create the .git/info/exclude
file either as a symbolic link or as a regular file.
We’ll see later on how to solve this question.
Bazaar uses the same model as Git to ignore files, but also has two features which don’t have an equivalent into Git. The complete description may be found in the documentation. The two features are:
-
"!!" allows you to ignore certain file patterns even if they’re specified using a "!" rule.
-
"RE:" at the beginning of a line allows you to specify a Python regular expression (Git only allows shell globs).
As a consequence, there are two different situations to consider:
-
If the
.bzrignore
file does not contain any of these two specific prefixes, then you can simply make a symbolic link to it in the repository:ln -s .bzrignore .git/info/exclude
-
Otherwise, you must create the
.git/info/exclude
file and adapt it to ignore exactly the same files in.bzrignore
.
Whatever the case is, you will have to remain vigilant against any change of .bzrignore
to make sure that the .git/info/exclude
file always reflects .bzrignore
.
Indeed, if the .bzrignore
file were to change and contained one or more lines starting with "!!" or "RE:", Git not being able to interpret these lines, you’ll have to adapt your .git/info/exclude
file to ignore the same files as the ones ignored with .bzrignore
.
Moreover, if the .git/info/exclude
file was a symbolic link, you’ll have to first delete the symbolic link, copy .bzrignore
to .git/info/exclude
and then adapt the latter.
However, be careful with its creation because with Git it is impossible to re-include a file if a parent directory of that file is excluded.
To fetch the changes of the remote, you pull changes as usually, using Git commands.
Supposing that your changes are on the master
-branch, you merge or rebase your work on the origin/master
-branch:
$ git pull --rebase origin
Because Bazaar also has the concept of merge commits, there will be no problem if you push a merge commit.
So you can work on a branch, merge the changes into master
and push your work.
Then, you create your branches, you test and commit your work as usual.
You finally push your work to the Bazaar repository:
$ git push origin master
Git’s remote-helpers framework has some limitations that apply. In particular, these commands don’t work:
-
git push origin :branch-to-delete (Bazaar can’t accept ref deletions in this way.)
-
git push origin old:new (it will push 'old')
-
git push --dry-run origin branch (it will push)