Stash and restore work with git stash

Park half-finished changes, switch branches or pull cleanly, then bring them back with one command.

LinuxstashworkflowgitLow risk
Run git stash push -m "wip: login fix" to shelve changes and git stash pop to restore the latest stash when you return.

01Command

Command
$ git stash push -m "wip: login fix"

02What it does

git stash snapshots your working tree and index, then resets both to HEAD — without creating a commit. Stashes live on a stack (stash@{0} is newest), so git stash list shows all of them, stash apply re-applies without removing, and pop removes after applying. A -m message keeps multiple stashes identifiable, unlike the anonymous default.

03Risk

RiskLow risk
Requirementsgit (any version from the last decade); a local repository. Stashes are local only — they are never pushed.
!Warning: Untracked files are NOT stashed unless you add -u (git stash push -u), a classic way to 'lose' new files that are actually still on disk. Conflicts on pop can leave the stash in place — resolve, commit, then drop it manually, and never treat a stash as a backup.

04Undo

Undo
$ git stash pop

05Sources

  • git-stash - Official Git documentation
    git-scm.com · community · 2026-09-17
    Evidence: Official docs for git stash push/list/pop/apply/drop, including stash@{0} refs and -m message handling.
  • git-stash(1) — Debian bookworm
    Debian Manpages · community · 2026-09-17
    Evidence: Documents git stash push with -m message, plus list, show, pop, apply and drop subcommands.

Last verified: 2026-09-19 · Category: Developer