# Git Stash

> Put your changes to one side for now. Then bring them back when you are ready.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** Stash

## Think of it like

Think of it like toys in a drawer while you eat. After dinner, you take them out again.

## Definition

Git stash puts your unsaved changes aside and leaves your files clean. It is useful when you need to switch branches but are not ready to commit. The changes go onto a pile, newest on top. Later, git stash pop puts them back where you left off. A stash stays on your computer only and is never pushed.

## Example

Jack is halfway through a change when a bug report comes in. He stashes his work, fixes the bug on main, then pops the stash.

## Example code

```console
$ git stash
Saved working directory and index state WIP on main: 26b91bd Blue greeting
$ git stash list
stash@{0}: WIP on main: 26b91bd Blue greeting
```

The half-done work is set aside, and the files are clean again.

## Why it matters

You can drop what you are doing for an urgent job. No messy half-done commit is needed.

## Common mistake

Stashing and forgetting. Old stashes pile up, and nobody remembers what is in them.

## Three principles

- **Set work aside.** Changes leave your files for now.
- **Pop to get back.** git stash pop restores them.
- **Local only.** A stash is never pushed.

## Related terms

- [Working Directory](https://learn.benibix.com/term/development/working-directory)
- [Commit](https://learn.benibix.com/term/development/commit)
- [Branch](https://learn.benibix.com/term/development/branch)
- [Staging Area](https://learn.benibix.com/term/development/staging-area)

## Taught in

- [Git Stash and Git Tags](https://learn.benibix.com/learn/development-version-control/git-stash-and-git-tags): Git and GitHub, 8/13

---

Source: https://learn.benibix.com/term/development/git-stash
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
