Search code examples
gitgit-stash

intended flow when git stash pop gets conflicts


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.


Solution

  • '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).