完成git reset后恢复添加的文件--hard HEAD ^ [英] Recovering added file after doing git reset --hard HEAD^
问题描述
我添加了一个新文件F1,并对另一个文件F2进行了更改,但之后执行了git reset --hard HEAD ^,并且我已经丢失了文件的所有更改。
有没有 SOME 方式,我可以让他们回来。
我在这里看到一个相关的问题:如何撤消git reset --hard HEAD〜1?但是,该问题假设你可以(有些工作)在最后一个git add中恢复文件的状态。
<文件> 。您可以使用 $ git fsck --cache --no-reflogs --lost-found --unreachable HEAD
然后检查'.git / lost-found / other'目录中的文件。
请阅读 git fsck manpage。
I added a new file F1 and made changes to another file F2 but then did a "git reset --hard HEAD^" and I have lost all the changes to the files.
Is there SOME way, I can get them back.
I did look at a related question here: How can I undo git reset --hard HEAD~1? but, that question assumes that the one has done a git commit.
You can (with some work) recover state of file at the last "git add <file>". You can use
$ git fsck --cache --no-reflogs --lost-found --unreachable HEAD
and then examine files in '.git/lost-found/other' directory.
Please read git fsck manpage.
这篇关于完成git reset后恢复添加的文件--hard HEAD ^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!