如何在意外运行“git clean -df”后恢复文件? [英] How can I recover files after accidentally running "git clean -df"?

查看:2573
本文介绍了如何在意外运行“git clean -df”后恢复文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心运行了 git clean -df 。它从我当前的提交中删除了我的文件,我尚未推送。现在,在 git status 中,这些文件被标记为 D ,这意味着已删除。

I have accidentally run git clean -df. It removed my files from my current commit, which I had yet to push. Now, in git status, those files are marked with D, which means "deleted".

有什么方法可以恢复这些文件吗?

Is there any way to get those files back?

推荐答案

git clean 只有未跟踪的文件和未提交的文件。

git clean only untracked files and not committed ones.

如果您看到 D 作为已提交文件的状态,您可能已经完成了其他操作。

You might have done other operations if you see D as the status for already committed files.

你找回这些文件,做到:

You get back those files, do:

git checkout .

git reset --hard

这篇关于如何在意外运行“git clean -df”后恢复文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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