Skip to content

Commit 97bc00a

Browse files
wincentgitster
authored andcommitted
Emit helpful status for accidental "git stash" save
If the user types "git stash" mistakenly thinking that this will list their stashes he/she may be surprised to see that it actually saved a new stash and reset their working tree and index. In the worst case they might not know how to recover the state. So help them by telling them exactly what was saved and also how to restore it immediately. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2f7ee08 commit 97bc00a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-stash.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ save_stash () {
9999

100100
git update-ref -m "$stash_msg" $ref_stash $w_commit ||
101101
die "Cannot save the current status"
102-
printf >&2 'Saved "%s"\n' "$stash_msg"
102+
printf >&2 'Saved working directory and index state "%s"\n' "$stash_msg"
103103
}
104104

105105
have_stash () {
@@ -228,7 +228,9 @@ create)
228228
*)
229229
if test $# -eq 0
230230
then
231-
save_stash && git-reset --hard
231+
save_stash &&
232+
echo >&2 '(To restore them type "git stash apply")' &&
233+
git-reset --hard
232234
else
233235
usage
234236
fi

0 commit comments

Comments
 (0)