git - git stash pop 成功后如何恢复我的 git stash

标签 git git-stash

我更改了一些文件和一些新文件

git pull: 说我在几个文件中有冲突

我做到了:

git stash
git pull
git stash pop

我预计会发生冲突,但没有发生。

相反,许多文件现在只是空的。 当前未提交的更改显示从这些文件中删除的所有内容。

我看到的解决方案是:克隆存储库。 “以某种方式恢复”我最后 pop 的存储并将其保存为补丁并在那里应用。

我如何恢复它(它不再在 stash 列表中)

我没有看到最后的存储使用:

gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

git fsck --no-reflog | awk '/dangling commit/ {print $3}'

给出:

error: object file .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669 is empty
error: object file .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669 is empty
fatal: loose object 027745a5151a6237eb1dcd8e4f0df10328809669 (stored in .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669) is corrupt

我该怎么办?发生了什么事?

最佳答案

我发现官方文档有解决办法。

Recovering stash entries that were cleared/dropped erroneously

If you mistakenly drop or clear stash entries, they cannot be recovered through the normal safety mechanisms. However, you can try the following incantation to get a list of stash entries 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

关于git - git stash pop 成功后如何恢复我的 git stash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35186393/

相关文章:

Git - 将代码推送到两个 Remote

git - gitlab如何防止ssh作为用户git

git - 如何在每次从 master pull 后将本地更改应用到 git repo 而无需推送到 master

git - 使用 git stash save 或 git commit 进行本地更改?

git - 如何从gitlab pull 项目?

android - Git repo 同步 - 连接丢失

git - 如何在不 merge 或 rebase 的情况下解决分支上的 git 冲突

git - 未更改的文件在 git stash 后显示在未暂存列表中

git - 我怎样才能 stash 我的更改并返回到我上次在 Git 中 checkin 的状态?

git - Git Stash 存储在哪里?