As you've discovered, the --all
flag (note two dashes here) means all files, including untracked and ignored files. This flag can also be spelled -a
(one dash, and a
by itself).1 There is a different flag, --include-untracked
or -u
, which means all files, including untracked files, but not including untracked-and-ignored files.2
It's important to understand how git stash
works. This has become fancier than the last time I described it, because git stash
can now build restricted stashes based on pathspecs. Still, it's worth reading through How to recover from "git stash save --all"? The stash code still uses the two-or-three commit mechanism I describe there, and still runs the equivalent of git reset
and git clean
: it's just that if you do provide a pathspec, the commits made, and the files reset and/or cleaned, are restricted.
In your particular case, interrupting git stash push
could have left you with several stashes and a partially-cleaned repository. Subsequent additional stashes would then save the partially-cleaned state. The rewrite from shell code to C code makes this sort of piecemeal behavior less likely, but you might be using a version of Git that still uses a shell script to implement git stash
.
Recovery would be a matter of finding all of the commits made, and using them to get the files back.
1As with most POSIX (Unix-style) commands, "long" options like all
are predeced by two dashes, and "short" (single letter) options are preceded by a single dash (hence git diff -c
vs git diff --cc
: the long cc
option requires two dashes; -cc
specifies the short c
option twice, to no effect).
2All ignored files are, by Git's own definition, also untracked files, but not all untracked files are ignored. This comes about because the definition of an ignored file is a file that is present in your working tree, but absent from Git's index. The definition of a tracked file is a file that is present in Git's index. If a file is present in Git's index, it's tracked, and therefore not ignored. If it's untracked, it's absent from Git's index. It then can be ignored, but isn't necessarily ignored.