从git reset复原--hard? [英] Recover from git reset --hard?
问题描述
有没有办法从 git reset --hard HEAD
中恢复对工作目录的未提交更改?
You 无法取回一般的未提交更改。
以前执行的变更( git add
)应该可以从索引对象中恢复,所以如果你这样做的话,可以使用 git fsck --lost-found
来找到与它相关的对象。
如果不是,这里的答案是:看看你的备份。 也许你的编辑器/ IDE存储临时拷贝在/ tmp或者C:\ TEMP之下以及类似的东西[1]
git reset HEAD @ {1}
这会恢复到前一个HEAD
[1] vim 例如可选地存储持久性撤销, eclipse IDE存储本地历史记录;这些功能可能会节省您的**
Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD
?
You cannot get back uncommitted changes in general.
Previously staged changes (git add
) should be recoverable from index objects, so if you did, use git fsck --lost-found
to locate the objects related to it.
If not, the answer here would be: look at your backup. Perhaps your editor/IDE stores temp copies under /tmp or C:\TEMP and things like that.[1]
git reset HEAD@{1}
This will restore to the previous HEAD
[1] vim e.g. optionally stores persistent undo, eclipse IDE stores local history; such features might save your a**
这篇关于从git reset复原--hard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!