US Trends

what does git stash do

git stash temporarily saves your uncommitted changes and restores your working directory to a clean state so you can switch branches or tasks without committing yet. You can later bring those changes back with git stash apply or git stash pop.

What it does

  • Saves modified, staged, and sometimes untracked work in a stash stack.
  • Cleans your working directory so Git looks like you haven’t made those local changes.
  • Lets you return to the saved work later, which is handy when you need to switch context fast.

Common uses

  • Jump to another branch to fix something urgent.
  • Pause work in progress without making a messy commit.
  • Keep local changes safe while you test or rebase.

Simple example

If you’re halfway through a feature and need to switch branches:

bash

git stash
git checkout other-branch
# do urgent work
git checkout your-branch
git stash pop

apply keeps the stash after restoring it, while pop restores it and removes it from the stash list.

If you want, I can also show the difference between git stash, git commit, and git reset in one quick table.