Git Stash Guide — Save & Restore Work in Progress
Git stash lets you save uncommitted changes without committing them, so you can switch branches or pull updates cleanly. Build stash commands with the interactive tool above.
Build git commands visually or browse the cheat sheet. Select an operation, fill in parameters, and copy the result.
Initialize Repository
Create a new Git repositorygit init
Quick Tips
- Use
git switchinstead ofgit checkoutfor switching branches (Git 2.23+) - Prefer
--force-with-leaseover--forceto avoid overwriting others' work - Use
git reflogto recover lost commits
Basic stash workflow
git stash saves your uncommitted changes (staged and unstaged) and reverts the working tree to HEAD. git stash pop restores the most recent stash and removes it from the stash list. This is the most common pattern: stash, switch branches, do work, switch back, pop.
# Git Stash — temporarily save uncommitted changes
git stash # stash tracked changes
git stash -u # include untracked files
git stash push -m "WIP: auth feature" # with a description
git stash list # view all stashes
# stash@{0}: WIP: auth feature
# stash@{1}: WIP on main: abc1234
git stash pop # apply latest + remove from stash
git stash apply stash@{1} # apply specific stash (keep it)
git stash drop stash@{0} # delete a stash
git stash clear # delete all stashesAdvanced stash usage
Use git stash push -m 'description' to label stashes. git stash --include-untracked saves new untracked files too. git stash apply restores without removing from the list (useful when applying to multiple branches). git stash branch <name> creates a new branch from a stash.
Frequently Asked Questions
Does git stash save untracked files?
By default, no. Use git stash --include-untracked (or -u) to also stash new files that have not been added to git. Use --all to include ignored files too.
How do I stash only specific files?
Use git stash push <file1> <file2> to stash specific files. Or use git stash push -p for interactive mode where you can select individual hunks to stash.
Related Generate Tools
Color Palette Generator
Generate harmonious color palettes using color theory algorithms
Box Shadow Generator
Design CSS box shadows visually with multiple layers, presets, and live preview
Flexbox Generator
Build CSS flexbox layouts visually with live preview, item config, and presets
Grid Generator
Build CSS grid layouts visually with columns, rows, gap, item placement, and presets