I ran git stash pop
and got some conflicts. It’s a similar experience to conflicts from a rebase or merge, and I’ve been resolving them.
I don’t really understand what flow I’m supposed to be following though. At the bottom of the output it says: The stash entry is kept in case you need it again.
This leaves me confused re: what to do once I resolve all the conflicts. Am I supposed to pop again, similar to how you continue a rebase after resolving conflicts? In this case it seems like that wouldn’t make as much sense, because it’s only 1 thing that is getting merged in.
Most importantly, what I’m wondering is whether all of my stashed files were added back to my working set of files. If so, then I think I could safely delete the stash, but that also leaves me wondering why it was kept in the first place.
‘git stash pop’ is basically telling Git “Try to run ‘git stash apply’ and if it succeeds delete the stash entry. If it fails(because you have conflicts) then it saves the stash.” Running ‘git stash apply’ will apply the changes but keep the stash entry.
So in your case it says The stash entry is kept in case you need it again.
because ‘git stash apply’ failed due to conflicts. The flow is basically resolve the conflicts, then delete the stash entry(assuming you don’t need it any longer).
1
Imagine if it didn’t. You try to apply it, get merge conflicts, get frustrated and give up. What if it popped it from the stash? Well now you can’t easily get it back because it’s gone from the stash which means it is an unreachable commit. Now you search StackOverflow for how to get it back and find a question with 2557 points and an answer which tells you how to fish out unreachable commits with git-fsck(1).
The stash is kept in case you fail and need to try again. You don’t need to try again if you already tried and succeeded.