Volume XXII, number 279Tuesday, October 6, 2026Latest message 8 minutes ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

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

1 messages between Aug 19, 2026 and Aug 19, 2026, from Yuri.

Plain Markdown or JSON for tools and agents.

YuriAug 19, 2026, 02:17 UTC on lore

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

Back to recent threads

'git stash' is not atomic: it leaves both an invalid stash and file changes | The Git List