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.

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.

Practice

A real repo, pre-seeded with history, runs right here — stage, commit, branch, stash, diff, even hit and resolve a real merge conflict. Nothing to install, nothing leaves your machine.

Open practice playground

Go deeper with