DevBolt
Processed in your browser. Your data never leaves your device.

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.

GitCommand Builder

Build git commands visually or browse the cheat sheet. Select an operation, fill in parameters, and copy the result.

Tools/Git Command Builder

Initialize Repository

Create a new Git repository
Generated Command
git init

Quick Tips

  • Use git switch instead of git checkout for switching branches (Git 2.23+)
  • Prefer --force-with-lease over --force to avoid overwriting others' work
  • Use git reflog to 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