~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-12-08 01:00:58 UTC
  • mfrom: (3095 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3133.
  • Revision ID: aaron.bentley@utoronto.ca-20071208010058-1vuj9qn49qfu808e
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
don't want version controlled, you can use the ``remove``
21
21
command to tell Bazaar to forget about it.
22
22
 
23
 
``remove`` has been designed to *Do the Right Thing* in
24
 
that it will leave the file on disk if it hasn't been
25
 
committed yet but delete it otherwise. For example::
 
23
``remove`` has been designed to *Do the Safe Thing* in
 
24
that it will not delete a modified file. For example::
26
25
 
27
26
  bzr add foo.html
28
27
  (oops - didn't mean that)
29
28
  bzr remove foo.html
 
29
 
 
30
This will complain about the file being modified or unknown.
 
31
If you want to keep the file, use the ``--keep`` option.
 
32
Alternatively, if you want to remove the file, use the ``--force`` option.
 
33
For example::
 
34
 
 
35
  bzr add foo.html
 
36
  (oops - didn't mean that)
 
37
  bzr remove --keep foo.html
30
38
  (foo.html left on disk)
31
39
 
32
 
On the other hand::
 
40
On the other hand, the ``TODO`` file is deregistered and
 
41
removed from disk without complaint in this example::
33
42
 
34
43
  bzr add TODO
35
44
  bzr commit -m "added TODO"
37
46
  bzr remove TODO
38
47
  (TODO file deleted)
39
48
 
40
 
If you want to insist on keeping the file, use the ``--keep`` option.
41
 
If you want to insist on removing the file, use the ``--force`` option.
42
 
 
43
49
Note: If you delete a file using your file manager, IDE or via an operating
44
50
system command, the ``commit`` command will implicitly treat it as removed.
45
51
 
53
59
 
54
60
  bzr revert
55
61
 
56
 
As a precaution, it is good practice to use ``bzr diff`` first to
57
 
check that everything being thrown away really ought to be.
 
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
really ought to be.
58
65
 
59
66
Undoing changes to a file since the last commit
60
67
-----------------------------------------------
82
89
  bzr uncommit
83
90
  bzr commit -m "Fix bug #1"
84
91
 
85
 
Undoing an earlier commit
86
 
-------------------------
87
 
 
88
 
You can use the -r option to undo several commits like this:
 
92
Another common reason for undoing a commit is because you forgot to add
 
93
one or more files. Some users like to alias ``commit`` to ``commit --strict``
 
94
so that commits fail if unknown files are found in the tree.
 
95
 
 
96
Note: While the ``merge`` command is not introduced until the next
 
97
chapter, it is worth noting now that ``uncommit`` restores any pending
 
98
merges. (Running ``bzr status`` after ``uncommit`` will show these.)
 
99
``merge`` can also be used to effectively undo just a selected commit
 
100
earlier in history. For more information on ``merge``, see `Merging changes`_
 
101
in the next chapter and the Bazaar User Reference.
 
102
 
 
103
Undoing multiple commits
 
104
------------------------
 
105
 
 
106
You can use the -r option to undo several commits like this::
89
107
 
90
108
  bzr uncommit -r -3
91
109