git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 26, 2022, 20:23 UTC
Message-ID
<xmqq4k5qqma2.fsf@gitster.g>
In-Reply-To
<4493bcea-c7dd-da0a-e811-83044b3a1cac@tsoft.com>
Yuri <yuri@rawbw.com> 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".

Previous: John Cai
Message 11 of 11 in “'git stash push' isn't atomic when Ctrl-C is pressed”
  1. YuriJan 25, 2022
  2. Ævar Arnfjörð BjarmasonJan 26, 2022
  3. John CaiJan 26, 2022
  4. Ævar Arnfjörð BjarmasonJan 26, 2022
  5. Junio C HamanoJan 26, 2022
  6. Ævar Arnfjörð BjarmasonJan 26, 2022
  7. Junio C HamanoJan 26, 2022
  8. Ævar Arnfjörð BjarmasonJan 27, 2022
  9. Junio C HamanoJan 27, 2022
  10. John CaiJan 27, 2022
  11. Junio C HamanoJan 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.