X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2Fgit-stash.txt;h=051f94d26f9f057cbd4db0d6886ca1a4d33c912c;hb=5fdb70983585ccde1540563a8c7458621f7a7407;hp=a4cbd0ce60e73b4e1ec9ffadfaeee132f7ea054b;hpb=656b50345239293929ad8c639c5f1941c6b867ad;p=git.git diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index a4cbd0ce6..051f94d26 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -8,11 +8,13 @@ git-stash - Stash the changes in a dirty working directory away SYNOPSIS -------- [verse] -'git stash' list -'git stash' (show | apply | drop | pop ) [] +'git stash' list [] +'git stash' (show | drop | pop ) [] +'git stash' apply [--index] [] 'git stash' branch [] -'git stash' [save []] +'git stash' [save [--keep-index] []] 'git stash' clear +'git stash' create DESCRIPTION ----------- @@ -39,12 +41,15 @@ is also possible). OPTIONS ------- -save []:: +save [--keep-index] []:: 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 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 []:: @@ -59,7 +64,7 @@ stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation stash@{1}: On master: 9cc0589... Add git-stash ---------------------------------------------------------------- + -The command takes options applicable to the `git-log` +The command takes options applicable to the 'git-log' command to control what is shown and how. See linkgit:git-log[1]. show []:: @@ -67,7 +72,7 @@ show []:: Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no `` is given, shows the latest one. By default, the command shows the diffstat, but - it will accept any format known to `git-diff` (e.g., `git stash show + it will accept any format known to 'git-diff' (e.g., `git stash show -p stash@\{1}` to view the second most recent stash in patch form). apply [--index] []:: @@ -113,6 +118,11 @@ pop []:: of the current working tree state. When no `` is given, `stash@\{0}` is assumed. See also `apply`. +create:: + + Create a stash (which is a regular commit object) and return its + object name, without storing it anywhere in the ref namespace. + DISCUSSION ---------- @@ -149,7 +159,7 @@ perform a pull, and then unstash, like this: + ---------------------------------------------------------------- $ git pull -... + ... file foobar not up to date, cannot merge. $ git stash $ git pull @@ -164,7 +174,7 @@ make a commit to a temporary branch to store your changes away, and return to your original branch to make the emergency fix, like this: + ---------------------------------------------------------------- -... hack hack hack ... +# ... hack hack hack ... $ git checkout -b my_wip $ git commit -a -m "WIP" $ git checkout master @@ -172,18 +182,36 @@ $ edit emergency fix $ git commit -a -m "Fix in a hurry" $ git checkout my_wip $ git reset --soft HEAD^ -... continue hacking ... +# ... continue hacking ... ---------------------------------------------------------------- + -You can use `git-stash` to simplify the above, like this: +You can use 'git-stash' to simplify the above, like this: + ---------------------------------------------------------------- -... hack hack hack ... +# ... hack hack hack ... $ git stash $ edit emergency fix $ git commit -a -m "Fix in a hurry" $ git stash apply -... continue hacking ... +# ... 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 -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