/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to doc/en/user-guide/undoing_mistakes.txt

  • Committer: Robert Collins
  • Date: 2010-05-05 00:05:29 UTC
  • mto: This revision was merged to the branch mainline in revision 5206.
  • Revision ID: robertc@robertcollins.net-20100505000529-ltmllyms5watqj5u
Make 'pydoc bzrlib.tests.build_tree_shape' useful.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
Mistakes happen
5
5
---------------
6
6
 
7
 
Breezy has been designed to make it easy to
 
7
Bazaar has been designed to make it easy to
8
8
recover from mistakes as explained below.
9
9
 
10
10
Dropping the revision history for a project
11
11
-------------------------------------------
12
12
 
13
13
If you accidentally put the wrong tree under version control, simply
14
 
delete the ``.brz`` directory.
 
14
delete the ``.bzr`` directory.
15
15
 
16
16
Deregistering a file or directory
17
17
---------------------------------
18
18
 
19
19
If you accidentally register a file using ``add`` that you
20
20
don't want version controlled, you can use the ``remove``
21
 
command to tell Breezy to forget about it.
 
21
command to tell Bazaar to forget about it.
22
22
 
23
23
``remove`` has been designed to *Do the Safe Thing* in
24
24
that it will not delete a modified file. For example::
25
25
 
26
 
  brz add foo.html
 
26
  bzr add foo.html
27
27
  (oops - didn't mean that)
28
 
  brz remove foo.html
 
28
  bzr remove foo.html
29
29
 
30
30
This will complain about the file being modified or unknown.
31
31
If you want to keep the file, use the ``--keep`` option.
32
32
Alternatively, if you want to delete the file, use the ``--force`` option.
33
33
For example::
34
34
 
35
 
  brz add foo.html
 
35
  bzr add foo.html
36
36
  (oops - didn't mean that)
37
 
  brz remove --keep foo.html
 
37
  bzr remove --keep foo.html
38
38
  (foo.html left on disk, but deregistered)
39
39
 
40
40
On the other hand, the unchanged ``TODO`` file is deregistered and
41
41
removed from disk without complaint in this example::
42
42
 
43
 
  brz add TODO
44
 
  brz commit -m "added TODO"
 
43
  bzr add TODO
 
44
  bzr commit -m "added TODO"
45
45
  (hack, hack, hack - but don't change TODO)
46
 
  brz remove TODO
 
46
  bzr remove TODO
47
47
  (TODO file deleted)
48
48
 
49
49
Note: If you delete a file using your file manager, IDE or via an operating
57
57
decide that the changes you have made since the last ``commit`` ought
58
58
to be thrown away, the command to use is ``revert`` like this::
59
59
 
60
 
  brz revert
 
60
  bzr revert
61
61
 
62
 
As a precaution, it is good practice to use ``brz status`` and
63
 
``brz diff`` first to check that everything being thrown away
 
62
As a precaution, it is good practice to use ``bzr status`` and
 
63
``bzr diff`` first to check that everything being thrown away
64
64
really ought to be.
65
65
 
66
66
Undoing changes to a file since the last commit
70
70
keep all the other changes in the tree, pass the filename as an argument
71
71
to ``revert`` like this::
72
72
 
73
 
  brz revert foo.py
 
73
  bzr revert foo.py
74
74
 
75
75
Undoing the last commit
76
76
-----------------------
78
78
If you make a commit and really didn't mean to, use the ``uncommit`` command
79
79
to undo it like this::
80
80
 
81
 
  brz uncommit
 
81
  bzr uncommit
82
82
 
83
83
Unlike ``revert``, ``uncommit`` leaves the content of your working tree
84
84
exactly as it is. That's really handy if you make a commit and accidently
85
85
provide the wrong error message. For example::
86
86
 
87
 
  brz commit -m "Fix bug #11"
 
87
  bzr commit -m "Fix bug #11"
88
88
  (damn - wrong bug number)
89
 
  brz uncommit
90
 
  brz commit -m "Fix bug #1"
 
89
  bzr uncommit
 
90
  bzr commit -m "Fix bug #1"
91
91
 
92
92
Another common reason for undoing a commit is because you forgot to add
93
93
one or more files. Some users like to alias ``commit`` to ``commit --strict``
94
94
so that commits fail if unknown files are found in the tree.
95
95
 
96
 
Tags for uncommitted revisions are removed from the branch unless
97
 
``--keep-tags`` was specified.
98
 
 
99
96
Note: While the ``merge`` command is not introduced until the next
100
97
chapter, it is worth noting now that ``uncommit`` restores any pending
101
 
merges. (Running ``brz status`` after ``uncommit`` will show these.)
 
98
merges. (Running ``bzr status`` after ``uncommit`` will show these.)
102
99
``merge`` can also be used to effectively undo just a selected commit
103
100
earlier in history. For more information on ``merge``, see
104
101
`Merging changes <merging_changes.html>`_ in the next chapter and the
105
 
Breezy User Reference.
 
102
Bazaar User Reference.
106
103
 
107
104
Undoing multiple commits
108
105
------------------------
109
106
 
110
107
You can use the -r option to undo several commits like this::
111
108
 
112
 
  brz uncommit -r -3
 
109
  bzr uncommit -r -3
113
110
 
114
111
If your reason for doing this is that you really want to
115
112
back out several changes, then be sure to remember that ``uncommit``
126
123
``revert`` to take your working tree back to the desired state.
127
124
For example::
128
125
 
129
 
  % brz commit "Fix bug #5"
 
126
  % bzr commit "Fix bug #5"
130
127
  Committed revision 20.
131
128
  (release the code)
132
129
  (hmm - bad fix)
133
 
  brz revert -r 19
134
 
  brz commit -m "Backout fix for bug #5"
 
130
  bzr revert -r 19
 
131
  bzr commit -m "Backout fix for bug #5"
135
132
 
136
133
This will change your entire tree back to the state as of revision 19,
137
134
which is probably only what you want if you haven't made any new commits
143
140
Note: As an alternative to using an absolute revision number (like 19), you can
144
141
specify one relative to the tip (-1) using a negative number like this::
145
142
 
146
 
  brz revert -r -2
 
143
  bzr revert -r -2
147
144
 
148
145
Correcting a tag
149
146
----------------
151
148
If you have defined a tag prematurely, use the ``--force`` option of
152
149
the ``tag`` command to redefine it. For example::
153
150
 
154
 
  brz tag 2.0-beta-1
 
151
  bzr tag 2.0-beta-1
155
152
  (oops, we're not yet ready for that)
156
153
  (make more commits to include more fixes)
157
 
  brz tag 2.0-beta-1 --force
 
154
  bzr tag 2.0-beta-1 --force
158
155
 
159
156
Clearing a tag
160
157
--------------
162
159
If you have defined a tag and no longer want it defined, use the
163
160
``--delete`` option of the ``tag`` command to remove it. For example::
164
161
 
165
 
  brz tag 2.0-beta-4
 
162
  bzr tag 2.0-beta-4
166
163
  (oops, we're not releasing a 4th beta)
167
 
  brz tag 2.0-beta-4 --delete
 
164
  bzr tag 2.0-beta-4 --delete
168
165