git stash pop. Don’t do it!
git. I love
stash. But if I was a smart person, I would always
git stash apply.
git stash pop loses your most recent stashed changes. If what
popped conflicts with your working tree, the resulting merge will
conflict. But the
stash is long gone because it was
popped onto the
working tree. So you have a mess to clean up. Messes are no fun.
The problem is if I
stash in the wrong place, it’s no longer
stashed. If I’m unlucky I see
UU (unmerged, both modified)
UU means I can’t re-
stash my changes.
UU is the worst.
If only I’d
git stash applyed. Then the changes would still be on the
stash. I could
git reset . without losing them. I could
figure out what I did wrong and fix it. At which point
apply would work, and I’d be set.
The only downside to
apply is it leaves the most recent
on top of the
stash forever. It pollutes the
poped on the wrong branch, I now have
to untangle things. The idea of a polluted stash seems a lot better
than losing changes.
git makes it impossible to mess up. Used right,
makes your code immortal. Live on the edge, no consequences! Do
crazy shit! If it doesn’t work out—even if it blows up in your face!—a
git reset . fixes everything. Or
git checkout -b
oops/this-didnt-go-so-well; git commit -m "but anyway…" isolates the
git checkout - and you’re right where you started, sins
forgiven, ready to move on. Whatever didn’t work out is still just an
oops branch away.