Git & GitHub · Lesson 83 of 144
Stashing Work
Git stash.
You're halfway through a feature, with messy, unfinished changes. Suddenly, you need to fix an urgent bug on main. You're not ready to commit. Git stash puts your changes on a shelf, so you can come back to them later.

- Halfway through a feature
- An urgent bug appears
- Put your changes on a shelf
git stash
Status shows our half-done change to the home page. Git stash saves it, and cleans up the working folder. Status is now clean, so we're free to switch branches and fix the bug.
git
git status --short M index.html git stash Saved working directory and index state WIP on main: f63a17a Link to about page git status --short
Getting it back
The bug is fixed. Now git stash pop takes our changes off the shelf, and puts them back into our files. Status shows the home page is modified again, exactly as we left it.
git
git stash pop On branch main Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.html no changes added to commit (use "git add" and/or "git commit -a") Dropped refs/stash@{0} (b0728d09524d6d42e54a151882e0a095bbb1bb63) git status --short M index.html
Summary
Git stash shelves unfinished changes, and git stash pop brings them back. Next, managing several stashes.
Key takeaways- git stash
- Switch, fix, come back
- git stash pop
Next up: More About Stash — list, messages and new files