Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Data Science
  3. Question
Data Science

Difference between git stash pop and git stash apply

Asked by Fujiwara Ban Jul 14, 2021 31.5K views 3 answers
Share

About this question

I've been using git stash pop for quite some time. I recently found out about the git stash apply command. When I tried it out, it seemed to work the same as git stash pop.

What is the difference between git stash pop and git stash apply?

Your answer

3 Answers

Wilfordgleichner Latest answer

Answered on Apr 14, 2025

Similarities

Both commands apply the current stash to your working directory.

  • They will try to merge the changes (Geometry Vibes) in the stash with your current code.
If there is a conflict, both can cause a conflict.

Differences

  • git stash apply: Applies the stash to the working directory, but does not delete the stash.
  • git stash pop: Applies and deletes the stash from the stash list.

Was this helpful?

Ranjana Admin JanBask Expert

Answered on Apr 23, 2024

The difference between git stash pop and git stash apply lies in how they handle the changes stored in the Git stash:


git stash pop:

This command applies the most recently stashed changes to your working directory and index.

After applying the changes, the stash entry is removed from the stash list.

If there are conflicts while applying the changes, git stash pop will stop and prompt you to resolve the conflicts before continuing.

git stash apply:

This command applies the most recently stashed changes to your working directory and index, similar to git stash pop.

However, unlike git stash pop, the stash entry is not removed from the stash list after applying the changes.

If there are conflicts while applying the changes, git stash apply will apply as many changes as it can and leave the conflicts for you to resolve manually. You can then use git stash drop to remove the stash entry after resolving the conflicts if desired.

In summary, git stash pop is convenient if you want to apply and remove the most recent stash entry in one step, while git stash apply allows you to apply changes from the stash without removing the stash entry, providing more flexibility in managing your stashed changes.

Was this helpful?

More Data Science discussions