~bzr-pqm/bzr/bzr.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Undoing mistakes
================

Mistakes happen
---------------

Bazaar has been designed to make it easy to
recover from mistakes as explained below.

Dropping the revision history for a project
-------------------------------------------

If you accidently put the wrong tree under version control, simply
delete the ``.bzr`` directory.

Deregistering a file or directory
---------------------------------

If you accidently register a file using ``add`` that you
don't want version controlled, you can use the ``remove``
command to tell Bazaar to forget about it.

``remove`` has been designed to *Do the Right Thing* in
that it will leave the file on disk if it hasn't been
committed yet but delete it otherwise. For example::

  bzr add foo.html
  (oops - didn't mean that)
  bzr remove foo.html
  (foo.html left on disk)

On the other hand::

  bzr add TODO
  bzr commit -m "added TODO"
  (hack, hack, hack - but don't change TODO)
  bzr remove TODO
  (TODO file deleted)

If you want to insist on keeping the file, use the ``--keep`` option.
If you want to insist on removing the file, use the ``--force`` option.

Note: If you delete a file using your file manager, IDE or via an operating
system command, the ``commit`` command will implicitly treat it as removed.

Undoing changes since the last commit
-------------------------------------

One of the reasons for using a version control tool is that it
lets you easily checkpoint good tree states while working. If you
decide that the changes you have made since the last ``commit`` ought
to be thrown away, the command to use is ``revert`` like this::

  bzr revert

As a precaution, it is good practice to use ``bzr diff`` first to
check that everything being thrown away really ought to be.

Undoing changes to a file since the last commit
-----------------------------------------------

If you want to undo changes to a particular file since the last commit but
keep all the other changes in the tree, pass the filename as an argument
to ``revert`` like this::

  bzr revert foo.py

Undoing the last commit
-----------------------

If you make a commit and really didn't mean to, use the ``uncommit`` command
to undo it like this::

  bzr uncommit

Unlike ``revert``, ``uncommit`` leaves the content of your working tree
exactly as it is. That's really handy if you make a commit and accidently
provide the wrong error message. For example::

  bzr commit -m "Fix bug #11"
  (damn - wrong bug number)
  bzr uncommit
  bzr commit -m "Fix bug #1"

Undoing an earlier commit
-------------------------

You can use the -r option to undo several commits like this:

  bzr uncommit -r -3

If your reason for doing this is that you really want to
back out several changes, then be sure to remember that ``uncommit``
does not change your working tree: you'll probably need to run the
``revert`` command as well to complete the task. In many cases though,
it's arguably better to leave your history alone and add a new
revision reflecting the content of the last good state.

Reverting to the state of an earlier version
--------------------------------------------

If you make an unwanted change but it doesn't make sense to uncommit
it (because that code has been released to users say), you can use
``revert`` to take your working tree back to the desired state.
For example::

  % bzr commit "Fix bug #5"
  Committed revision 20.
  (release the code)
  (hmm - bad fix)
  bzr revert -r 20
  bzr commit -m "Backout fix for bug #5"

Correcting a tag
----------------

If you have defined a tag prematurely, use the ``--force`` option of
the ``tag`` command to redefine it. For example::

  bzr tag 2.0-beta-1
  (oops, we're not yet ready for that)
  bzr tag 2.0-beta-1 --force

Clearing a tag
--------------

If you have defined a tag and no longer want it defined, use the
``--delete`` option of the ``tag`` command to remove it. For example::

  bzr tag 2.0-beta-4
  (oops, we're not releasing a 4th beta)
  bzr tag 2.0-beta-4 --delete