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

'git stash' is not atomic: it leaves both an invalid stash and file changes

From
YYuri <yuri@rawbw.com>
Date
Aug 19, 2026, 02:17 UTC
Message-ID
<6b5dbe00-690e-402f-9f55-ba708c3a4ef5@rawbw.com>

My repository had many untracked files that were accidentally added, one of them was 2GB. My first attempt failed: $ git stash push ../../ -m "all-accidentally-added" Saved working directory and index state On main: all-accidentally-added fatal: unable to generate diff for misc/linux-rl9-cuda13/libcuda.txt

Two problems with this:
1. it didn't say why did it fail to generate diff.
It should have said "fatal: unable to generate diff for 
misc/linux-rl9-cuda13/libcuda.txt: file is 2GB which is larger than the 
limit 1GB"
2. This command left both stash and file changes. If the command has 
failed, why does it leave stash then?

After removing the large file 'git stash' still failed: $ git stash push ../../ -m "all-accidentally-added-final" Saved working directory and index state On main: all-accidentally-added-final error: patch too large

Again: "patch too large" needs to specify the limit, and the transaction 
should be atomic.

Please consider improving error messages to be more informative as for the reasons of failure. Also please consider making stash atomic. The stash that was left was obviously invalid because it didn't contain at least one file.

Yuri
Message 1 of 1 in “'git stash' is not atomic: it leaves both an invalid stash and file changes”
  1. YuriAug 19, 2026

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.