'Reverting Git Stash Pop
I executed git stash pop
twice instead of once and am now getting the following warning.
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: package-lock.json
both modified: static_compiled/img/about-bg.jpg
both modified: static_compiled/img/contact-bg.jpg
both modified: static_compiled/img/home-bg.jpg
both modified: static_compiled/img/logo.png
both modified: static_compiled/img/post-bg.jpg
both modified: static_compiled/img/post-sample-image.jpg
Is there a way to revert the second pop?
Solution 1:[1]
As a general rule: no. This is one of my many objections to git stash
(not just to git stash pop
, which is a particularly egregious offender, but to the entire git stash
subsystem).
For some specific cases, if you can find the second diff that was applied, you can reverse-apply it. Unfortunately, you've hit a conflict case and that's one of the specific cases where this doesn't work. You're thus squarely in the general "no" case.
In the future, consider using git stash apply
. That means do the apply step, but don't do the drop step yet. The git stash pop
command means do the apply, and then if you, Git, think the apply went well, do the drop too. It's the drop step that "loses" the effect that you got from the "apply" step and makes it difficult to un-apply in those (not all that rare, but also not all that common either) special cases where a reverse-apply / un-apply would work. But that doesn't help you with what you are stuck with now.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | torek |