Skip to content

Commit caf1899

Browse files
Eric Raiblegitster
authored andcommitted
Documentation: tweak use case in "git stash save --keep-index"
The documentation suggests using "git stash apply" in the --keep-index workflow even though doing so will lead to clutter in the stash. And given that the changes are about to be committed anyway "git stash pop" is more sensible. Additionally the text preceeding the example claims that it works for "two or more commits", but the example itself is really tailored for just two. Expanding it just a little makes it clear how the procedure generalizes to N commits. Finally the example is annotated with some commentary to explain things on a line-by-line basis.
1 parent 7bedebc commit caf1899

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Documentation/git-stash.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,14 @@ each change before committing:
180180
+
181181
----------------------------------------------------------------
182182
... hack hack hack ...
183-
$ git add --patch foo
184-
$ git stash save --keep-index
185-
$ build && run tests
186-
$ git commit -m 'First part'
187-
$ git stash apply
188-
$ build && run tests
189-
$ git commit -a -m 'Second part'
183+
$ git add --patch foo # add just first part to the index
184+
$ git stash save --keep-index # save all other changes to the stash
185+
$ edit/build/test first part
186+
$ git commit foo -m 'First part' # commit fully tested change
187+
$ git stash pop # prepare to work on all other changes
188+
... repeat above five steps until one commit remains ...
189+
$ edit/build/test remaining parts
190+
$ git commit foo -m 'Remaining parts'
190191
----------------------------------------------------------------
191192

192193
SEE ALSO

0 commit comments

Comments
 (0)