Lesson Completion
Back to course

Listing Stashes

Beginner
7 minutes4.7Git

The Hook (The "Byte-Sized" Intro)

If you stash and forget, you'll end up with a pile of mystery boxes. git stash list shows every stash you've saved — with index, branch, and message. But that's just the start. You can also diff a stash, show its contents, and check what files it touched — all without applying it. Knowledge is power; inspect before you pop.

📖 What is Listing Stashes?

Listing stashes means viewing all saved stash entries and inspecting their contents. Each entry sits on a stack and can be examined individually.

Conceptual Clarity

Reading stash list output:

stash@{0}: On feature/login: WIP: add validation stash@{1}: On main: WIP: fix header styling stash@{2}: WIP on main: a1b2c3d Initial commit
PartMeaning
stash@{0}Index — 0 is the most recent
On feature/login:Branch the stash was created on
WIP: add validationYour message (or auto-generated label)

Inspection commands:

CommandWhat It Shows
git stash listAll stash entries (index, branch, message)
git stash showFiles changed in the latest stash (summary)
git stash show -pFull diff of the latest stash (patch)
git stash show stash@{2}Summary for a specific stash
git stash show -p stash@{2}Full diff for a specific stash

Real-Life Analogy

git stash list is like checking the label on each storage box on a shelf. git stash show is like opening a box to peek inside without taking anything out.

Visual Architecture

flowchart TD STACK["📦 Stash Stack"] --> S0["stash@{0}<br/>WIP: validation"] STACK --> S1["stash@{1}<br/>WIP: header fixes"] STACK --> S2["stash@{2}<br/>WIP: old experiment"] S0 -->|"git stash show -p"| DIFF["📝 Full Diff"] style STACK fill:#0f3460,stroke:#53d8fb,color:#53d8fb style S0 fill:#1a1a2e,stroke:#ffd700,color:#ffd700 style DIFF fill:#1a1a2e,stroke:#e94560,color:#e94560

Why It Matters

  • Discovery: Find that stash you created 3 days ago.
  • Verification: See exactly what a stash contains before applying it.
  • Safety: Inspect contents to make sure you're applying the right stash.
  • Cleanup: Identify old, no-longer-needed stashes to drop.

Code

bash
# ─── List all stashes ─── git stash list # Output: # stash@{0}: On feature/login: WIP: add validation # stash@{1}: On main: WIP: fix header styling # ─── Show files changed in the latest stash ─── git stash show # Output: # src/login.js | 12 +++++++++--- # src/auth.js | 5 +++++ # 2 files changed, 14 insertions(+), 3 deletions(-) # ─── Show full diff (patch) of the latest stash ─── git stash show -p # Shows the actual line-by-line changes # ─── Inspect a specific stash ─── git stash show stash@{1} git stash show -p stash@{1} # ─── Show stash with stat + diff combined ─── git stash show --stat -p stash@{0}

Key Takeaways

  • git stash list shows all stashes with index, branch, and message.
  • git stash show gives a summary; add -p for the full diff.
  • Always inspect a stash before applying it to avoid surprises.
  • Indexes start at 0 (most recent) and count up.

Interview Prep

  • Q: How do you see what changes are in a specific stash? A: Use git stash show stash@{N} for a summary of files changed, or git stash show -p stash@{N} for the full line-by-line diff.

  • Q: What does stash@{0} refer to? A: The most recently created stash entry. Stashes work as a stack — the newest is always at index 0, and older stashes shift to higher indexes.

  • Q: Can you view a stash's changes without applying it? A: Yes. git stash show -p displays the full diff without modifying your working tree. This lets you verify the contents before deciding to apply or drop the stash.

Topics Covered

Git StashingGit Fundamentals

Tags

#git#stash#list#beginner-friendly

Last Updated

2026-02-12