@matheusbsbs / matheus-bagliano / commits / caf1899699
Fork 0

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.

Eric Raible committed Jul 8, 2008 at 00:40 UTC caf1899699b2255111a3db335553e31f3718c1c9
1 file changed +8 -7
Documentation/git-stash.txt
+8 -7
@@ -180,13 +180,14 @@ each change before committing:
180 +
181 ----------------------------------------------------------------
182 ... 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'
191 ----------------------------------------------------------------
192
193 SEE ALSO