Subject: Re: 'git stash push' isn't atomic when Ctrl-C is pressed

From: Junio C Hamano <[email-masked]>
Date: Wed, 26 Jan 2022 12:23:17 -0800

Yuri <[email-masked]> writes:

> Ctrl-C was pressed in the middle. git creates the stash record and
> didn't update the files.

If you kill a program in the middle, bad things can happen ;-)

In this case, however, recovery is very easy.

Because you know that a stash entry was created that records the
local changes, if you want to finish "git stash push" (in other
words, if you wish you didn't kill "git stash push" in the middle),
you can "git reset --hard" yourself, because by definition, after
"git stash push" records all the local changes, it would have
cleared any and all local changes.  Or if you truly regret you
started "git stash push" in the first place, then you can still "git
reset --hard" and then "git stash pop".  The first step will let the
"git stash push" to "finish", and then popping the local changes
recorded in there will restore the state before you started running
"git stash push".