# git stash — Git

Source: https://www.geekswithgeeks.com/en/git/git-stash

> Temporarily shelve uncommitted changes to switch context.

## Shelve and restore

Stash saves your dirty working directory and reverts it to a clean state, so you can switch branches instantly.

```bash
git stash
# ...switch branches, fix something urgent...
git stash pop
```

Output:

```
Saved working directory and index state WIP on main: a1b2c3d ...
```

## Multiple stashes

Stashes stack up — list and pick which one to restore.

```bash
git stash list
git stash apply stash@{1}
```

## pop vs apply

`stash pop` applies and deletes the stash entry; `stash apply` applies but keeps it around in case you need it again.
