git stash list 被 git stash clear 清空后的还原步骤:
git stash list 被 git stash clear 清空后的还原步骤:
正常情况下使用如下命令调出stash 的log,该log 对应stash 的栈缓存纪录,WIP 为midify 内容,index 为add 内容,所以,一般情况下,WIP 比index 内容要全
命令1. git log --graph --oneline --decorate $(git fsck --no-reflog | awk '/dangling commit/ {print $3}')
找到对应hash值后, 使用git show hash_id 查看是否你想要找回的提交
如果是 则使用 命令2: git stash apply hash_id 即可,
注: 网上也有使用 (git merge hash_id) 的, 但此命令会引起合并跳跃, 不建议使用
如果以 命令1 执行时报错类似:
error: Could not read 21be13d39d121300b49f8888d36fd6661d359edc
fatal: revision walk setup failed
则可以使用 git fsck --no-reflog | awk '/dangling commit/ {print $3}'|xargs git show 方法直接查看详情, 即类似 git log 查看
如果感觉此方法不方便 也可以 使用 git fsck --no-reflog | awk '/dangling commit/ {print $3}'|xargs git show > xx.log
将信息打到 xx.log 文件里, 然后打开xx.log 搜索你要回原的内容, 找到后使用git stash apply hash_id恢复数据