summaryrefslogtreecommitdiffstats
path: root/git-stash.txt
diff options
context:
space:
mode:
authorJunio C Hamano <junio@hera.kernel.org>2008-07-14 03:13:27 +0000
committerJunio C Hamano <junio@hera.kernel.org>2008-07-14 03:13:27 +0000
commit46a38aa8be7b8f7b5afdeeea0744859b3e03d5a2 (patch)
tree109cac450de2a01929e22f1db123b486d14a7d25 /git-stash.txt
parent208beb7160e9d42ed3938d959525e6d89c642e39 (diff)
downloadgit-htmldocs-46a38aa8be7b8f7b5afdeeea0744859b3e03d5a2.tar.gz
Autogenerated HTML docs for v1.5.6.3-315-g10ce0
Diffstat (limited to 'git-stash.txt')
-rw-r--r--git-stash.txt42
1 files changed, 40 insertions, 2 deletions
diff --git a/git-stash.txt b/git-stash.txt
index 9b6b91109..7d50d74cc 100644
--- a/git-stash.txt
+++ b/git-stash.txt
@@ -8,8 +8,11 @@ git-stash - Stash the changes in a dirty working directory away
SYNOPSIS
--------
[verse]
-'git stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>])
+'git stash' list
+'git stash' (show | apply | drop | pop ) [<stash>]
+'git stash' branch <branchname> [<stash>]
'git stash' [save [<message>]]
+'git stash' clear
DESCRIPTION
-----------
@@ -36,12 +39,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>]::
@@ -81,6 +87,20 @@ tree's changes, but also the index's ones. However, this can fail, when you
have conflicts (which are stored in the index, where you therefore can no
longer apply the changes as they were originally).
+branch <branchname> [<stash>]::
+
+ Creates and checks out a new branch named `<branchname>` starting from
+ the commit at which the `<stash>` was originally created, applies the
+ changes recorded in `<stash>` to the new working tree and index, then
+ drops the `<stash>` if that completes successfully. When no `<stash>`
+ is given, applies the latest one.
++
+This is useful if the branch on which you ran `git stash save` has
+changed enough that `git stash apply` fails due to conflicts. Since
+the stash is applied on top of the commit that was HEAD at the time
+`git stash` was run, it restores the originally stashed state with
+no conflicts.
+
clear::
Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover.
@@ -169,6 +189,24 @@ $ 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 # add just first part to the index
+$ git stash save --keep-index # save all other changes to the stash
+$ edit/build/test first part
+$ git commit foo -m 'First part' # commit fully tested change
+$ git stash pop # prepare to work on all other changes
+... repeat above five steps until one commit remains ...
+$ edit/build/test remaining parts
+$ git commit foo -m 'Remaining parts'
+----------------------------------------------------------------
+
SEE ALSO
--------
linkgit:git-checkout[1],