Loading

Quipoin Menu

Learn • Practice • Grow

git / Stashing Changes
tutorial

Stashing Changes

Sometimes you’re in the middle of work but need to switch branches urgently. You don’t want to commit incomplete code. Git stash lets you temporarily save your changes and clean your working directory.

What Is Stash?

Stashing takes your uncommitted changes (both staged and unstaged), saves them on a stack, and reverts your working directory to the last commit. You can later reapply the stashed changes.

Stashing Your Changes

To save your current changes:
git stash
You can add a message for clarity:
git stash push -m "WIP: login feature"

Listing Stashes

See all stashed entries:
git stash list
Output shows something like: stash@{0}: On main: WIP: login feature

Applying Stashed Changes

To apply the most recent stash and keep it in the stash list:
git stash apply
To apply and also remove it from the stash list:
git stash pop
You can apply a specific stash: git stash apply stash@{1}

Dropping Stashes

To remove a stash without applying it:
git stash drop stash@{0}
To clear all stashes:
git stash clear


Two Minute Drill
  • git stash saves uncommitted changes and cleans the working directory.
  • View stashes with git stash list.
  • git stash apply reapplies changes but keeps the stash.
  • git stash pop reapplies and removes the stash.
  • Drop a stash with git stash drop.

Need more clarification?

Drop us an email at career@quipoinfotech.com