重置后--hard我所有未跟踪的文件都消失了 [英] After reset --hard all my untracked files are gone

查看:103
本文介绍了重置后--hard我所有未跟踪的文件都消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有提交文件就进行了git硬重置.触发重置后,我检查了所有未跟踪的文件都消失了.我希望它只会影响我们在提交过程中所做的更改,并且只会重置这些更改.但是我错了.

I did a git hard reset without committing my files. After firing reset I checked all my untracked files are gone. I am expecting it will affect only the changes we made during the commit and it will simply reset those changes. But I was wrong.

有什么办法可以恢复我所有未跟踪的文件?任何帮助将不胜感激.

Is there any way to get recover all my untracked files ? Any Help would be really really appreciated.

谢谢

推荐答案

如果您以前对未跟踪的文件进行了git add,则git reset --hard将删除它们. Git没有还原这些文件的过程,因为它们没有被追踪.您将需要找到其他工具来执行此操作,例如您的操作系统或IDE. IntelliJ有一个本地历史记录"工具,您也许可以利用它来还原这些文件.

If you previously did a git add with your untracked files, then git reset --hard will delete them. Git has no process of restoring these because they are untracked. You will need to find another tool to do so, such as your operating system or IDE. IntelliJ has a "Local History" tool that you might be able to leverage for restoring these files.

为将来参考,与git reset --hard相比,更优选git stash. git stash使用您的更改创建一个临时的隐藏"提交.这些可以使用git stash applygit stash pop轻松检索.当您使用git reset --hard核对工作目录时,撤消会更加困难,有时甚至是不可能的.

For future reference, prefer git stash to git reset --hard. git stash creates a temporary "stash" commit with your changes. These can be easily retrieved with git stash apply or git stash pop. When you nuke your working directory with git reset --hard, it is much more difficult to undo, sometimes even impossible.

这篇关于重置后--hard我所有未跟踪的文件都消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆