I had to stash a bunch of work I was doing in a project to shift gears and do something that suddenly became higher priority. No problem, I assumed. But when I finished that work and came back and typed
git show stash@{0}
I only saw a tiny fraction of my work—in fact only one file!
Fortunately, before digging through my backups to find what would presumably be an earlier and incomplete version of my work, I opened VS Code and used GitLens for showing stashes, and to my surprise and relief, it contained everything I expected.
After popping the stash, I noticed the pattern: git show stash@{0}
had neither shown the staged file nor the many new (untracked) files.
(I normally stash with git stash save -u
, and pop with git stash pop --index
, because when I stash I don't want to lose anything.)
But I've never noticed this limitation in git show
when used with stashes before (perhaps because I pop much sooner and remember exactly what was there), and I couldn't find anything in the options section of git show
that controls which things are visible from the stash. I also couldn't find anything in my ~/.gitconfig
that would change the behavior of git show
.
So I'm baffled: why did git show stash@{0}
not show me everything in the specified stash? And how can I make it show me everything.
(Of course I could just use VS Code with GitLens, but I prefer to at least have the option to use the command line for Git whenever possible. The ability to script and customize everything makes it more efficient for most things that are a part of my regular workflow, in my opinion.)