Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to Git
Git Stash: Save Changes Temporarily

Git Stash: Save Changes Temporarily

Git2,958 viewsBy Admin
gitstashsavechangestemporarily

What is Git Stash?

Git stash temporarily shelves your uncommitted changes so you can switch branches or pull updates, then restore them later — without committing half-done work.

Basic Usage

git stash            # save changes & clean working dir
git stash list       # see stashes
git stash pop        # restore latest & remove from stash
git stash apply      # restore but keep in stash

A Common Workflow

# You're mid-feature but need to fix a bug on main
git stash               # shelve your work
git checkout main
# fix the bug, commit
git checkout feature
git stash pop           # get your work back

Useful Variations

git stash save "message"   # named stash
git stash -u               # include untracked files
git stash drop             # delete a stash
git stash clear            # delete all

FAQs

pop vs apply?

pop removes the stash after restoring; apply keeps it. More in our Git guides.

Can I stash specific files?

Yes — git stash push file.js.