Skip to content

Commit a902927

Browse files
committed
Fix git stash apply examples
The console output for these git stash apply examples didn't reflect reality.
1 parent 89ed85e commit a902927

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

book/07-git-tools/sections/stashing-cleaning.asc

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ If you don’t specify a stash, Git assumes the most recent stash and tries to a
6767
[source,console]
6868
----
6969
$ git stash apply
70-
# On branch master
71-
# Changed but not updated:
72-
# (use "git add <file>..." to update what will be committed)
73-
#
74-
# modified: index.html
75-
# modified: lib/simplegit.rb
76-
#
70+
On branch master
71+
Changes not staged for commit:
72+
(use "git add <file>..." to update what will be committed)
73+
(use "git checkout -- <file>..." to discard changes in working directory)
74+
75+
modified: index.html
76+
modified: lib/simplegit.rb
77+
78+
no changes added to commit (use "git add" and/or "git commit -a")
7779
----
7880

7981
You can see that Git re-modifies the files you reverted when you saved the stash.
@@ -88,17 +90,17 @@ If you had run that instead, you’d have gotten back to your original position:
8890
[source,console]
8991
----
9092
$ git stash apply --index
91-
# On branch master
92-
# Changes to be committed:
93-
# (use "git reset HEAD <file>..." to unstage)
94-
#
95-
# modified: index.html
96-
#
97-
# Changed but not updated:
98-
# (use "git add <file>..." to update what will be committed)
99-
#
100-
# modified: lib/simplegit.rb
101-
#
93+
On branch master
94+
Changes to be committed:
95+
(use "git reset HEAD <file>..." to unstage)
96+
97+
modified: index.html
98+
99+
Changes not staged for commit:
100+
(use "git add <file>..." to update what will be committed)
101+
(use "git checkout -- <file>..." to discard changes in working directory)
102+
103+
modified: lib/simplegit.rb
102104
----
103105

104106
The apply option only tries to apply the stashed work – you continue to have it on your stack.
@@ -191,19 +193,22 @@ If you want an easier way to test the stashed changes again, you can run `git st
191193
[source,console]
192194
----
193195
$ git stash branch testchanges
194-
Switched to a new branch "testchanges"
195-
# On branch testchanges
196-
# Changes to be committed:
197-
# (use "git reset HEAD <file>..." to unstage)
198-
#
199-
# modified: index.html
200-
#
201-
# Changed but not updated:
202-
# (use "git add <file>..." to update what will be committed)
203-
#
204-
# modified: lib/simplegit.rb
205-
#
206-
Dropped refs/stash@{0} (f0dfc4d5dc332d1cee34a634182e168c4efc3359)
196+
M index.html
197+
M lib/simplegit.rb
198+
Switched to a new branch 'testchanges'
199+
On branch testchanges
200+
Changes to be committed:
201+
(use "git reset HEAD <file>..." to unstage)
202+
203+
modified: index.html
204+
205+
Changes not staged for commit:
206+
(use "git add <file>..." to update what will be committed)
207+
(use "git checkout -- <file>..." to discard changes in working directory)
208+
209+
modified: lib/simplegit.rb
210+
211+
Dropped refs/stash@{0} (29d385a81d163dfd45a452a2ce816487a6b8b014)
207212
----
208213

209214
This is a nice shortcut to recover stashed work easily and work on it in a new branch.

0 commit comments

Comments
 (0)