All commands

git stash

intermediate

Park your uncommitted changes and get a clean working tree.

What it does

git stash sweeps your staged and unstaged changes out of the working tree and stores them as specially-marked commit objects on the stash stack. Your worktree becomes clean instantly. You can pop the stash back anytime — even days later, even on another branch.

Working Tree

before git stash

src/wip.ts
docs/notes.md
env.local
packed away

Stash Stack

refs/stash · LIFO

stash@{0} WIP: login work
workspace is clean now

Changes are packed into a stash object and emptied from the worktree

Watch it — press play

A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.

1 / 3

Step 1

Interrupted mid-feature

Half-finished changes sit in your worktree, but you must switch branches now.

git stash

Working Tree

files on disk

src/wip.tsM
docs/notes.mdM
filtered in the index

Index · Staging

.git/index

src/wip.tsA
docs/notes.mdA
snapshot copied in

Repository

objects/ → commits

committed history

Uncommitted work you don't want to lose

Under the hood

1

A stash is a pair of commits

Git commits your index as one commit and your working-tree changes as a second, both hanging off your current HEAD under a special stash ref. That ref moves like a stack: push (stash) / pop (stash pop).

W-index = stash of staged
W's-worktree = stash of unstaged
stash@{0} → parent → your HEAD
2

The working tree is then forced clean

After recording, git stash resets the worktree to HEAD — quietly running the same file-discard logic as restore. Files that only existed locally become untracked unless -u was given.

3

The stack is ordered, not merged

stash@{0} is the newest. git stash pop applies and drops, git stash apply applies and keeps, git stash list shows all. Stashes are unmerged unless you explicitly apply.

Aliases the pros type

Memorize the git stash concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:

git config --global alias.st # → git stash -u --include-untracked
AliasWhy people use it
g s

Oh-my-zsh's default stash — safe, catches untracked files too.

g sa

Re-apply without popping (stack stays).

g sl

Survey the whole stack.

g sp

Restore the newest stash and drop it.

Command anatomy

git stash
-u

Also stash untracked files (otherwise they stay around).

push -m <msg>

Name the stash so you remember what it was.

pop

Apply the newest stash and remove it from the stack.

list / show

Inspect the stack without touching anything.

branch <name>

Create a branch at the stash's base and apply — conflict-annihilation.

When to reach for it

A client calls mid-feature; you need to switch branches NOW: stash, switch, work, switch back, pop.

You want to test one set of changes in isolation.

Your stash stack becomes a lightweight scratchpad of work-in-progress.

Pro tip

A stash is the only commit that belongs to no branch — dream state. If you never pop it, it's garbage-collected in 30 days by default (stash.stashExpire). Also: `git stash branch fix <stash>` makes conflicts vanish by placing the stash back where it belongs.

Go deeper with