Git Stash
Shelve dirty work, switch context, and restore it later.
- git stash
- stash pop
- stash untracked
- stash list
- stash apply
Git Stash
Shelve dirty work, switch context, and restore it later.
Commands
| Command | What it does |
|---|---|
git stash push -m "wip" | Stash tracked changes with a label |
git stash push -u -m "wip" | Include untracked files in the stash |
git stash list | List all stashes |
git stash pop | Restore and drop the latest stash |
git stash apply stash@{1} | Restore a specific stash, keep it stored |
git stash drop stash@{0} | Delete a stash entry |
Example
git stash push -u -m "half-done search"
git switch main && git pull
git switch - && git stash pop
FAQ
stash pop vs apply?
pop restores and deletes the entry; apply restores but keeps it, safer when unsure.
Where did my stashed files go?
They are commit-like objects in .git/refs/stash; git stash list shows every entry.
FAQ
stash pop vs apply?
pop restores and deletes the entry; apply restores but keeps it, safer when unsure.
Where did my stashed files go?
They are commit-like objects in .git/refs/stash; git stash list shows every entry.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.