git stash pop vs apply: save and restore changes - Rocketeers

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com) 

 On this page

 Knowledge
---------

git stash pop vs apply: save and restore changes
================================================

### [\#Development](https://rocketee.rs/index.php/development)

git stash shelves your uncommitted changes so you can switch context. git stash pop restores them and removes the stash; git stash apply restores them but keeps the stash around.

 Published by [Mark van Eijk](https://rocketee.rs/index.php/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [Stashing your changes](#content-stashing-your-changes)
2. [pop vs apply](#content-pop-vs-apply)
3. [Working with multiple stashes](#content-working-with-multiple-stashes)
4. [When pop hits a conflict](#content-when-pop-hits-a-conflict)

[\#](#content-stashing-your-changes "Permalink")Stashing your changes
---------------------------------------------------------------------

`git stash` takes your modified tracked files, saves them away, and gives you a clean working directory:

 ```
git stash

```

By default it does **not** include untracked files. Add `-u` to stash those too:

 ```
git stash -u

```

Give a stash a label so you can recognise it later:

 ```
git stash push -m "half-finished login form"

```

[\#](#content-pop-vs-apply "Permalink")pop vs apply
---------------------------------------------------

Both bring your changes back. The difference is what happens to the stash afterwards:

 ```
git stash pop     # restore the changes AND delete the stash entry
git stash apply   # restore the changes but KEEP the stash entry

```

Use `apply` when you want to restore the same changes onto more than one branch. Use `pop` for the normal "I'm back, give me my work" case.

[\#](#content-working-with-multiple-stashes "Permalink")Working with multiple stashes
-------------------------------------------------------------------------------------

List what you have stashed:

 ```
git stash list

```

 ```
stash@{0}: On main: half-finished login form
stash@{1}: WIP on feature: 3f9a1c2 ...

```

Apply or pop a specific one by its reference:

 ```
git stash apply stash@{1}
git stash pop stash@{1}

```

Drop a stash you no longer need, or clear them all:

 ```
git stash drop stash@{0}
git stash clear

```

[\#](#content-when-pop-hits-a-conflict "Permalink")When pop hits a conflict
---------------------------------------------------------------------------

If your stashed changes conflict with the current state of the files, `git stash pop` stops with merge conflicts and, importantly, **keeps the stash** so you do not lose it. Resolve the conflicts, stage the files, then drop the stash manually:

 ```
git stash drop

```

If you would rather permanently discard uncommitted changes than stash them, see [git reset --hard](/git-reset-hard).

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Development](https://rocketee.rs/index.php/development)

- [Install PHP memcached extension on macOS](https://rocketee.rs/index.php/install-php-memcached-extension-on-macos)
- [How to delete a local (and remote) Git branch](https://rocketee.rs/index.php/git-delete-local-branch)
- [Fix: Cannot connect to the Docker daemon at unix:///var/run/docker.sock](https://rocketee.rs/index.php/cannot-connect-to-docker-daemon)
- [How to clean up Docker with prune (images, volumes, system)](https://rocketee.rs/index.php/docker-prune)
- [What port does SSH use (and how to change it)](https://rocketee.rs/index.php/ssh-port)
- [How to checkout a Git tag](https://rocketee.rs/index.php/git-checkout-tag)

 [View all 12 articles →](https://rocketee.rs/index.php/development)
