Git stash
Git
git stash is Git's “clipboard” for uncommitted work.
What it actually does:
- Takes every tracked file that is modified (staged or unstaged) and saves the changes away in a special area (the “stash”).
- Reverts those files back to the state of the last commit, so your working tree and index look clean again.
- Leaves untracked files and ignored files alone unless you add options (
-u,-a).
The result: you can switch branches, pull, merge, etc. without committing half-done work.
Later you can bring the changes back with git stash pop (apply + drop) or git stash apply (keep a copy in the stash).
Quick recipe:
# save current dirty state
git stash push -m "WIP on login feature"
# …do something else…
# restore it
git stash pop
Think of it as “pause & bookmark” for your uncommitted edits.