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.
Advanced 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
QR Code Generator
Generate customizable QR codes from text or URLs
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