summaryrefslogtreecommitdiff
path: root/Documentation/git-stash.txt
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2008-06-27 14:37:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-05 18:22:13 (GMT)
commit7bedebcaad351108a8f6eab6a031f2be2c06b613 (patch)
treef6faf1fc4dd06fde0c9724188b17798e51e1576e /Documentation/git-stash.txt
parent6991357513bf8bfbb71a4675e271b386cc273476 (diff)
downloadgit-7bedebcaad351108a8f6eab6a031f2be2c06b613.zip
git-7bedebcaad351108a8f6eab6a031f2be2c06b613.tar.gz
git-7bedebcaad351108a8f6eab6a031f2be2c06b613.tar.bz2
stash: introduce 'stash save --keep-index' option
'git stash save' saves local modifications to a new stash, and runs 'git reset --hard' to revert them to a clean index and work tree. When the '--keep-index' option is specified, after that 'git reset --hard' the previous contents of the index is restored and the work tree is updated to match the index. This option is useful if the user wants to commit only parts of his local modifications, but wants to test those parts before committing. Also add support for the completion of the new option, and add an example use case to the documentation. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-stash.txt')
-rw-r--r--Documentation/git-stash.txt22
1 files changed, 21 insertions, 1 deletions
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 23ac331..8f331ee 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -36,12 +36,15 @@ is also possible).
OPTIONS
-------
-save [<message>]::
+save [--keep-index] [<message>]::
Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no
subcommand is given. The <message> part is optional and gives
the description along with the stashed state.
++
+If the `--keep-index` option is used, all changes already added to the
+index are left intact.
list [<options>]::
@@ -169,6 +172,23 @@ $ git stash apply
... continue hacking ...
----------------------------------------------------------------
+Testing partial commits::
+
+You can use `git stash save --keep-index` when you want to make two or
+more commits out of the changes in the work tree, and you want to test
+each change before committing:
++
+----------------------------------------------------------------
+... hack hack hack ...
+$ git add --patch foo
+$ git stash save --keep-index
+$ build && run tests
+$ git commit -m 'First part'
+$ git stash apply
+$ build && run tests
+$ git commit -a -m 'Second part'
+----------------------------------------------------------------
+
SEE ALSO
--------
linkgit:git-checkout[1],