4
What is a stacked branch?
5
-------------------------
7
A stacked branch is a branch that knows how to find revisions
8
in another branch. Stacked branches store just the
9
unique revisions, making them faster to create and more
10
storage efficient. In these respects, stacked branches are
11
similar to shared repositories. However, stacked branches have
14
* The new branch can be in a completely different location to the
15
branch being stacked on.
17
* Deleting the stacked branch really deletes the revisions (rather
18
than leaving them in a shared repository).
20
* Security is improved over shared repositories: developers with
21
access to a shared repository can programmatically get to all
22
revisions, while they cannot get to the local revisions in a stacked
23
branch in a secure location.
25
These benefits make stacked branches ideal for various scenarios
26
including experimental branches and code hosting sites.
29
Creating a stacked branch
30
-------------------------
32
To create a stacked branch, use the ``stacked`` option of the branch command.
35
bzr branch --stacked source-url my-dir
37
This will create ``my-dir`` as a stacked branch with no local revisions.
38
If it is defined, the public branch associated with ``source-url`` will be
39
used as the *stacked-on* location. Otherwise, ``source-url`` will be the
40
*stacked-on* location.
43
Creating a stacked checkout
44
---------------------------
46
Direct creation of a stacked checkout is expected to be supported soon.
47
In the meantime, a two step process is required:
49
1. Create a stacked branch as shown above.
51
2. Convert the branch into a checkout using either the ``reconfigure``
55
Pushing a stacked branch
56
------------------------
58
Most changes on most projects build on an existing branch such as the
59
*development trunk* or *current stable* branch. Creating a new
60
branch stacked on one of these is easy to do using the ``push``
63
bzr push --stacked-url reference-url new-url
65
This creates a new branch at ``my-url`` that is stacked on ``reference-url``
66
and only contains the revisions in the current branch that are not already
67
in the branch at ``reference-url``.
69
If the local branch was created as a stacked branch, then you can
70
use the ``--stacked`` option to ``push`` and the *stacked-on* location
71
will be implicit. For example::
73
bzr branch --stacked source-url my-dir
76
bzr commit -m "fix bug"
77
bzr push --stacked my-url
80
Limitations of stacked branches
81
-------------------------------
83
The important thing to remember about a stacked branch is that the
84
stacked-on branch needs to be available for many operations. This is
85
not an issue when both branches are local or both branches are on the