0

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.)

iconoclast
  • 21,213
  • 15
  • 102
  • 138
  • 2
    Or, rather than reading the duplicate, note that what you wanted to run is `git stash show`, not `git show`. It's unfortunate that both `git show` and `git stash` exist *and* `git show stash` *works* but does something useless. It's really easy to swap the order of the words; both work; and if you don't look at what they're showing, they both seem to be doing what you meant ... but as soon as you do look, only the right command actually *work*-works (if you know what I mean). – torek Apr 03 '19 at 00:50
  • (If you ask me, the whole mistaken-identity thing seems more like a sitcom than a version control system.) – torek Apr 03 '19 at 00:53
  • I can un-duplicate it if you like (I just did). But the answer to "why didn't your files appear" is because `git show` does something different, which to me, at least, immediately leads *to* [the other question](https://stackoverflow.com/q/21738579/1256452). – torek Apr 03 '19 at 02:02
  • yes, the other question might be a logical next question to ask – iconoclast Apr 03 '19 at 02:28
  • if you move your comment to an answer, I'll mark it as the accepted answer – iconoclast Apr 03 '19 at 02:29

0 Answers0