"git stash save" performs the steps "create-store-reset". Often, users try to use "stash save" as a way to to save their current state (index, worktree) before an operation like "checkout/reset --patch" they don't feel confident about, and are forced to do "git stash save && git stash apply". Provide an extra mode that does "create-store" only without the reset, so that one can "ceckpoint" the sate and keep working on it. Suggested-by: "Kyle J. McKay" <mackyle@xxxxxxxxx> Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> --- Notes: I'm not sure about how to best expose this mode: git stash checkpoint git stash save --checkpoint Maybe it is best to document the former and rename "--checkpoint" to "--no-reset"? Also, a "safe return" to a checkpoint probably requires git reset --hard && git stash pop although "git stash pop" will do in many cases. Should we provide a shortcut "restore" which does the reset-and-pop? git-stash.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git-stash.sh b/git-stash.sh index d4cf818..42f140c 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -193,12 +193,16 @@ store_stash () { } save_stash () { + checkpoint= keep_index= patch_mode= untracked= while test $# != 0 do case "$1" in + -c|--checkpoint) + checkpoint=t + ;; -k|--keep-index) keep_index=t ;; @@ -267,6 +271,11 @@ save_stash () { die "$(gettext "Cannot save the current status")" say Saved working directory and index state "$stash_msg" + if test -n "$checkpoint" + then + exit 0 + fi + if test -z "$patch_mode" then git reset --hard ${GIT_QUIET:+-q} @@ -576,6 +585,10 @@ save) shift save_stash "$@" ;; +checkpoint) + shift + save_stash "--checkpoint" "$@" + ;; apply) shift apply_stash "$@" -- 2.3.0.191.ge77e8b9 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html