If you have changes in your working directory that you're not ready to commit — for example, you need to switch to a different branch to fix a bug — `git stash` lets you save that uncommitted work without making a commit. Think of it as a clipboard for your in-progress changes.

## Saving for later

```bash
$ git stash
Saved working directory and index state WIP on main: 0dda643 Add edam
```

Any uncommitted changes (both staged and unstaged) will be saved and your working directory will be reset to match the last commit. You can now safely switch branches with [`git checkout`](/git/commands/git-checkout) or [`git branch`](/git/branching-and-merging).

## Stashing with a message

By default, stashes are labelled "WIP on branchname", which isn't very descriptive when you have several. You can add your own message:

```bash
$ git stash push -m "half-finished login form styling"
Saved working directory and index state On main: half-finished login form styling
```

This makes it much easier to identify stashes later.

## Stashing untracked files

By default, `git stash` only saves tracked files. If you also want to stash new files that haven't been added to Git yet, use the `-u` flag:

```bash
$ git stash -u
```

This is useful when you've created new files as part of your work-in-progress that you don't want to leave behind.

## Restoring your work

When you're ready to pick up where you left off, you have two options:

### Stash apply

```bash
$ git stash apply
```

This restores the most recent stash but keeps it in the stash list, so you can apply it again elsewhere if needed.

### Stash pop

```bash
$ git stash pop
```

This restores the most recent stash and removes it from the list. Use `pop` when you're done with the stash and don't need it any more.

## Viewing stash contents

To see what's in a stash before applying it, use `git stash show`:

```bash
$ git stash show
 assets/css/login.css | 12 +++++++++---
 templates/login.html |  4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)
```

Add the `-p` flag to see the full diff:

```bash
$ git stash show -p stash@{0}
```

## Managing multiple stashes

If you've stashed more than once, you can list everything:

```bash
$ git stash list
stash@{0}: On main: half-finished login form styling
stash@{1}: WIP on my-new-branch: 56aedbe remove old folder
```

Apply a specific stash by referencing its identifier:

```bash
$ git stash apply stash@{1}
```

## Dropping stashes

To remove a stash you no longer need:

```bash
$ git stash drop stash@{0}
```

Or clear all stashes at once:

```bash
$ git stash clear
```

You can check the current state of your working directory at any time with [`git status`](/git/commands/status) to confirm your stash has been applied or that your directory is clean.

---

When your work is committed and pushed, [DeployHQ](https://www.deployhq.com) can pick up the changes and deploy them to your servers automatically.
