Git & GitHub Interview Question #49
What is the difference between git stash apply and git stash pop?
Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash Mid-Level Intermediate
Quick Interview Answer
git stash apply reapplies a stash but normally keeps the stash entry in the stash list. git stash pop reapplies it and, when successful, removes that stash entry.
Detailed Explanation
git stash apply reapplies a stash but normally keeps the stash entry in the stash list. git stash pop reapplies it and, when successful, removes that stash entry.
apply is useful when you want to keep the saved stash until you verify the result. pop is convenient when you expect the stash to be consumed immediately.
Code Example
git stash list
git stash apply stash@{0}
# Or apply and remove it
git stash pop stash@{0}