我在进行复杂的合并之前隐藏了一些本地更改,进行了合并,然后愚蠢地忘记在运行之前提交git stash pop
。流行音乐产生了一些难以追踪的问题(大型代码库中的错误方法调用)。我跑了git stash show
,所以我至少知道哪些文件被更改了。如果不出意外,我想这是一个教训,要付出更多。
我的问题:是否可以在不撤消合并的情况下撤消存储弹出?
尝试使用如何在 Git 中恢复丢弃的存储?找到你弹出的藏匿处。我认为存储总是有两个提交,因为它保留了索引和工作副本(因此索引提交通常为空)。然后git show
他们查看差异并使用patch -R
取消应用它们。
从git stash --help
Recovering stashes that were cleared/dropped erroneously
If you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms. However, you can try the
following incantation to get a list of stashes that are still in your repository, but not reachable any more:
git fsck --unreachable |
grep commit | cut -d\ -f3 |
xargs git log --merges --no-walk --grep=WIP
这对我的帮助比在相同情况下接受的答案更好。
如果您的合并不是太复杂,另一种选择是:
之后,您只剩下过早丢弃的存储中的更改。