~bzr-pqm/bzr/bzr.dev

4119.2.2 by James Westby
Move the shelve docs from bzrtools to the main help.
1
Shelving Changes
2
================
3
4
Sometimes you will want to temporarily remove changes from your working
5
tree and restore them later, For instance to commit a small bug-fix you
6
found while working on something. Bazaar allows you to put changes on
7
a ``shelf`` to achieve this. When you want to restore the changes later
8
you can use ``unshelve`` to apply them to your working tree again.
9
10
For example, consider a working tree with one or more changes made ... ::
11
12
  $ bzr diff
13
  === modified file 'description.txt'
14
  --- description.txt
15
  +++ description.txt
16
  @@ -2,7 +2,7 @@
17
   ===============
18
   
19
   These plugins
20
  -by Michael Ellerman
21
  +written by Michael Ellerman
22
   provide a very
23
   fine-grained 'undo'
24
   facility
25
  @@ -11,6 +11,6 @@
26
   This allows you to 
27
   undo some of
28
   your changes,
29
  -commit, and get
30
  +perform a commit, and get
31
   back to where you
32
   were before.
33
34
The ``shelve`` command interactively asks which changes
35
you want to retain in the working tree::
36
37
  $ bzr shelve
38
  --- description.txt
39
  +++ description.txt
40
  @@ -2,7 +2,7 @@
41
   ===============
42
   
43
   These plugins
44
  -by Michael Ellerman
45
  +written by Michael Ellerman
46
   provide a very
47
   fine-grained 'undo'
48
   facility
49
50
  Shelve? [yNfrq?]: y
51
  --- description.txt
52
  +++ description.txt
53
  @@ -11,6 +11,6 @@
54
   This allows you to 
55
   undo some of
56
   your changes,
57
  -commit, and get
58
  +perform a commit, and get
59
   back to where you
60
   were before.
61
62
  Shelve? [yNfrq?]: n
63
  Shelve 2 change(s)? [yNfrq?]', 'y'
64
  Selected changes:
65
   M  description.txt
66
  Changes shelved with id "1".  
67
68
If there are lots of changes in the working tree, you
69
can provide the ``shelve`` command with a list of files
70
and you will only be asked about changes in those files.
71
After shelving changes, it's a good idea to use ``diff``
72
to confirm the tree has just the changes you expect::
73
74
  $ bzr diff
75
  === modified file 'description.txt'
76
  --- description.txt
77
  +++ description.txt
78
  @@ -2,7 +2,7 @@
79
   ===============
80
   
81
   These plugins
82
  -by Michael Ellerman
83
  +written by Michael Ellerman
84
   provide a very
85
   fine-grained 'undo'
86
   facility
87
88
Great - you're ready to commit::
89
90
  $ bzr commit -m "improve first sentence"
91
92
At some later time, you can bring the shelved changes back into the
93
working tree using ``unshelve``::
94
95
  $ bzr unshelve
96
  Unshelving changes with id "1".
97
   M  description.txt
98
  All changes applied successfully.
99
100
If you want to, you can put multiple items on the shelf.
101
Normally each time you run ``unshelve`` the most recently
102
shelved changes will be reinstated. However, you can also
103
unshelve changes in a different order by explicitly
104
specifying which changes to unshelve.
105
106
Bazaar merges the changes in to your working tree, so they
107
will apply even if you have edited the files since you shelved
108
them, though they may conflict, in which case you will have to
109
resolve the conflicts in the same way you do after a conflicted
110
merge.