What is a Stash
git stash saves your uncommitted changes (both staged and unstaged) and reverts the working tree to the last commit. You can restore the changes later with git stash pop.
How it works
Internally, stash creates two (or three) commit objects: one for the index state, one for the working tree changes, and optionally one for untracked files (git stash -u). These commits are stored on the ref refs/stash as a stack.
git stash # save changes
git stash list # show stash stack
git stash pop # restore latest and remove from stack
git stash apply # restore latest but keep in stack
git stash drop # discard latest stash
Stash entries are not on any branch — they are attached to a special ref. They follow the same object model as regular commits but are hidden from git log unless you specifically look at refs/stash.
Why it matters
Stash solves the "I need to switch branches but have uncommitted work" problem. Without stash, you would need to commit half-finished work or lose it. Stash is temporary storage — for longer-lived work-in-progress, a feature branch is more appropriate.
See How Git Internals Work for how stash entries interact with the reflog and garbage collection.