diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index f50c24ce9a..8dc35d493e 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -8,7 +8,7 @@ git-stash - Stash the changes in a dirty working directory away SYNOPSIS -------- [verse] -'git-stash' (list | show [] | apply [] | clear | drop []) +'git-stash' (list | show [] | apply [] | clear | drop [] | pop []) 'git-stash' [save []] DESCRIPTION @@ -90,6 +90,12 @@ drop []:: Remove a single stashed state from the stash list. When no `` is given, it removes the latest one. i.e. `stash@\{0}` +pop []:: + + Remove a single stashed state from the stash list and apply on top + of the current working tree state. When no `` is given, + `stash@\{0}` is assumed. See also `apply`. + DISCUSSION ---------- diff --git a/git-stash.sh b/git-stash.sh index 5e3eb56791..c2b68205a2 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (c) 2007, Nanako Shiraishi -USAGE='[ | save | list | show | apply | clear | drop | create ]' +USAGE='[ | save | list | show | apply | clear | drop | pop | create ]' SUBDIRECTORY_OK=Yes OPTIONS_SPEC= @@ -256,6 +256,14 @@ drop) shift drop_stash "$@" ;; +pop) + shift + if apply_stash "$@" + then + test -z "$unstash_index" || shift + drop_stash "$@" + fi + ;; *) if test $# -eq 0 then