7
Once someone has their own branch of a project, they can make
8
and commit changes in parallel to any development proceeding
9
on the original branch. Pretty soon though, these independent
10
lines of development will need to be combined again. This
11
process is known as *merging*.
16
To incorporate changes from another branch, use the ``merge`` command.
21
If no URL is given, a default is used, initially the branch this branch
23
For example, if Bill made a branch from Mary's work, he can merge her
24
subsequent changes by simply typing this::
28
On the other hand, Mary might want to merge into her branch the work Bill
29
has done in his. In this case, she needs to explicitly give the URL the
32
bzr merge sftp://mary@bill-laptop/cool-repo/cool-trunk
34
This sets the default merge branch if one is not already set. To change the
35
default after it is set, use the ``--remember`` option.
37
How does merging work?
38
----------------------
40
A variety of algorithms exist for merging changes. Bazaar's
41
default algorithm is a variation of *3-way merging* which
42
works as follows. Given an ancestor A and two branches B and C,
43
the following table provides the rules used.
45
=== === === ========================
47
=== === === ========================
52
=== === === ========================
54
Note that some merges can only be completed with the assistance
55
of a human. Details on how to resolve these are given in
56
`Resolving conflicts`_.
61
After any conflicts are resolved, the merge needs to be committed.
64
bzr commit -m "Merged Mary's changes"
66
Even if there are no conflicts, an explicit commit is still required.
67
Unlike some other tools, this is considered a feature in Bazaar.
68
A clean merge is not necessarily a good merge so making the commit
69
a separate explicit step allows you to run your test suite first to
70
verify all is good. If problems are found, you should correct them
71
before committing the merge or throw the merge away using ``revert``.
76
One of the most important features of Bazaar is distributed,
77
high quality *merge tracking*.
78
In other words, Bazaar remembers what has been merged already and
79
uses that information to intelligently choose the best ancestor for
80
a merge, minimizing the number and size of conflicts.
82
If you are a refugee from many other VCS tools, it can be really
83
hard to "unlearn" the *please-let-me-avoid-merging-at-any-cost* habit.
84
Bazaar lets you safely merge as often as you like with other people.
85
By working in a peer-to-peer manner when it makes sense to do so, you
86
also avoid using a central branch as an "integration swamp", keeping
87
its quality higher. When the change you're collaborating on is
88
truly ready for wider sharing, that's the time to merge and commit
89
it to a central branch, not before.
91
Merging that Just Works truly can change how developers work together.