Getting Started Git Basics Stash

Stash

Learn what Git stash stores and when it is useful.

Stash is a temporary place to store uncommitted changes so you can work on something else without committing unfinished work.

You can think of it as putting your current local edits on a shelf so you can return to them later.

Why people use stash

Stash is useful when you need to switch context quickly.

For example, you might use stash when:

  • You started working on one task but need to fix something urgent on another branch.
  • You want to pull or rebase, but your current uncommitted changes are in the way.
  • Your work is not ready for a real commit yet, but you do not want to lose it.

Stash is often a convenience tool for short-term interruption handling.

What gets stashed

In general, stash stores your uncommitted local changes so the worktree can return to a cleaner state.

Depending on how you use it, that can include:

  • Modified tracked files.
  • Staged changes.
  • Sometimes untracked files, if you explicitly include them.

The exact details depend on the stash command or UI action you use, but the main idea is the same: your current local changes are moved aside temporarily.

What happens after stashing

After a stash, your worktree usually becomes cleaner, which makes it easier to switch branches or do other Git operations.

The stashed work is still stored in the repository's stash list until you apply it, pop it, or delete it.

Restoring stashed work

Later, you can bring the stashed changes back.

Common actions include:

  • Apply: restore the stash but keep the stash entry.
  • Pop: restore the stash and remove it from the stash list if the restore succeeds.

If the repository changed a lot since the stash was created, applying a stash can sometimes cause conflicts that need manual resolution.

When not to use stash

Stash is useful, but it is not always the best long-term place for important work.

If a change is already meaningful and you may want to keep it, a normal commit on a branch is often easier to understand and safer to track than leaving it in stash for a long time.

Documentation

Search

move open Esc close

Browse the docs or start typing to filter results.