20
20
configured into numerous development and testing tools. Once
21
21
again, reusing a checkout across multiple branches can help.
23
24
Changing where a branch is bound to
24
25
-----------------------------------
34
35
3. Make your checkout a copy of the desired branch by using
35
36
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.
38
Note that simply binding to a new branch and running ``update``
39
merges in your local changes, both committed and uncommitted. You need
40
to decide whether to keep them or not by running either ``revert``
43
An alternative to the bind+update recipe is using the ``switch``
44
command. This is basically the same as removing the existing
45
branch and running ``checkout`` again on the new location, except
46
that any uncommitted changes in your tree are merged in.
48
Note: As ``switch`` can potentially throw away committed changes in
49
order to make a checkout an accurate cache of a different bound branch,
50
it will fail by design if there are changes which have been committed
51
locally but are not yet committed to the most recently bound branch.
52
To truly abandon these changes, use the ``--force`` option.
42
55
Switching a lightweight checkout
43
56
--------------------------------
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.
58
With a lightweight checkout, there are no local commits and ``switch``
59
effectively changes which branch the working tree is associated with.
50
60
One possible setup is to use a lightweight checkout in combination
51
61
with a local tree-less repository. This lets you switch what you
52
62
are working on with ease. For example::
61
71
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
72
but there will be no working tree there as the branch was created in
63
73
a tree-less repository. You can grab or create as many branches as you
64
74
need there and switch between them as required. For example::
71
81
bzr switch ../X-trunk
72
82
(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
84
Note: The branches may be local only or they may be bound to
81
85
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.
86
after creating them with ``branch``).