7
At times, it can be useful to have a single checkout as your
8
sandbox for working on multiple branches. Some possible reasons
11
* saving disk space when the working tree is large
12
* developing in a fixed location.
14
In many cases, working tree disk usage swamps the size of the
15
``.bzr`` directory. If you want to work on multiple branches
16
but can't afford the overhead of a full working tree for each,
17
reusing a checkout across multiples branches is the way to go.
19
On other occasions, the location of your sandbox might be
20
configured into numerous development and testing tools. Once
21
again, reusing a checkout across multiple branches can help.
23
Changing where a branch is bound to
24
-----------------------------------
26
To change where a checkout is bound to, follow these steps:
28
1. Make sure that any local changes have been committed
29
centrally so that no work is lost.
31
2. Use the ``bind`` command giving the URL of the new
32
remote branch you wish to work on.
34
3. Make your checkout a copy of the desired branch by using
35
the ``update`` command followed by the ``revert`` command.
38
Note that simply binding to a new branch
39
and running ``update`` is not enough: you need the ``revert`` to
40
throw away any local differences in the working tree.
42
Switching a lightweight checkout
43
--------------------------------
45
If you have a lightweight checkout, there is no local history
46
to worry about. In this case, you
47
can simply alter the branch that the checkout (i.e.
48
working tree) is referring to by using the ``switch`` command.
50
One possible setup is to use a lightweight checkout in combination
51
with a local tree-less repository. This lets you switch what you
52
are working on with ease. For example::
54
bzr init-repo --no-trees X-repo
56
bzr branch sftp://centralhost/srv/bzr/X-repo/X-trunk
57
bzr checkout --lightweight X-trunk my-sandbox
61
Note that X-trunk in this example will have a ``.bzr`` directory within it
62
but their will be no working tree there as the branch was created in
63
a tree-less repository. You can grab or create as many branches as you
64
need there and switch between them as required. For example::
66
(assuming in my-sandbox)
67
bzr branch sftp://centralhost/srv/bzr/X-repo/X-1.0 ../X-1.0
70
bzr commit -m "blah, blah blah"
72
(go back to working on the trunk)
74
In many ways, ``switch`` operates like ``update`` in that it
75
refreshes your working tree and merges in any local changes you
76
have made. The primary different is that ``switch`` requires
77
a branch location and it is only supported (currently) on
78
lightweight checkouts.
80
Note: The branches may be local only or they may be bound to
81
remote ones (by creating them with ``checkout`` or by using ``bind``
82
after creating them with ``branch``). ``switch`` and ``bind`` are
83
similar but different: switch controls which branch the working tree
84
refers to while ``bind`` associates a remote branch to the local one.