X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2Fgit-stash.txt;h=49e2296a24825b2ea3a0976ff9073e7b44e976d8;hb=652b0bbe09c909eb5aa34be8746071f1c5c0e73d;hp=8f331ee7d41ab5031e7b490e199dad7885e96a1a;hpb=7bedebcaad351108a8f6eab6a031f2be2c06b613;p=git.git diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 8f331ee7d..49e2296a2 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -8,8 +8,13 @@ git-stash - Stash the changes in a dirty working directory away SYNOPSIS -------- [verse] -'git stash' (list | show [] | apply [] | clear | drop [] | pop []) -'git stash' [save []] +'git stash' list [] +'git stash' (show | drop | pop ) [] +'git stash' apply [--index] [] +'git stash' branch [] +'git stash' [save [--keep-index] []] +'git stash' clear +'git stash' create DESCRIPTION ----------- @@ -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] []:: @@ -84,6 +89,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 []:: + + Creates and checks out a new branch named `` starting from + the commit at which the `` was originally created, applies the + changes recorded in `` to the new working tree and index, then + drops the `` if that completes successfully. When no `` + 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. @@ -99,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 ---------- @@ -161,7 +185,7 @@ $ git reset --soft HEAD^ ... 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 ... @@ -180,13 +204,14 @@ 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' +$ 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