Git development
 help / color / mirror / Atom feed
From: Yuri <yuri@rawbw.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: 'git stash' is not atomic: it leaves both an invalid stash and file changes
Date: Tue, 18 Aug 2026 19:17:30 -0700	[thread overview]
Message-ID: <6b5dbe00-690e-402f-9f55-ba708c3a4ef5@rawbw.com> (raw)

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





                 reply	other threads:[~2026-08-19  2:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b5dbe00-690e-402f-9f55-ba708c3a4ef5@rawbw.com \
    --to=yuri@rawbw.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox