Skip to content
Git Stash — Explained with Examples

Git Stash — Explained with Examples

DodaTech Updated Jun 15, 2026 2 min read

Git stash temporarily saves uncommitted changes so you can switch branches without committing unfinished work, then reapplies them later.

Git stash takes modified tracked files and staged changes, saves them on a stack, and reverts your working directory to a clean state. You can later reapply them with git stash pop or git stash apply. Stashes are identified by names like stash@{0} and can be listed, inspected, and managed.

Think of stashing like putting your books in a drawer when you need to clear your desk for a different task. You do not throw the books away — you store them temporarily and take them out when you are ready to continue reading.

Stashing is essential when you need to switch branches mid-task. For example, you are working on a feature but need to fix an urgent bug on main. Instead of committing half-baked code, you stash your changes, switch to main, fix the bug, switch back, and unstash.

# Save uncommitted changes
git stash save "WIP: login form validation"

# List all stashes
git stash list
# stash@{0}: On feature/login: WIP: login form validation

# Reapply and remove the latest stash
git stash pop

# Reapply without removing
git stash apply stash@{1}

Use git stash --include-untracked to also stash new files. Multiple stashes can accumulate, so name them descriptively to avoid confusion.

Git, Branch, Merge

Git Fundamentals

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro