Git不小心删除了我所有的更改 [英] Git accidentally deleted all of my changes

查看:118
本文介绍了Git不小心删除了我所有的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git中,我做了git rm -r .

这很愚蠢,因为显然它删除了我工作目录中的所有文件.这些文件中的许多文件都有尚未提交的更改.我当时很愚蠢,过去一周没有做任何事情.

This was stupid, because apparently it deleted all of my files in my working directory. Many of these files had changes that had not been commited. I was being stupid and didn't commit anything for the past week.

我该如何撤消呢?我想找回工作目录中的所有更改,而不是git的最后一次签入.

How can I undo this? I want to get back all the changes in my working directory NOT the last checkin on git.

当我运行git status时,它显示大约200个已删除的文件.其中许多更改在我要保留的工作目录中.我怎样才能做到这一点?

When I run git status, it shows about 200 files that were deleted. Many of these had changes in my working directory that I would like to keep. How can I do this?

推荐答案

您不能. Git删除了文件.他们走了.您也许可以使用某些文件恢复工具取消删除它们,但这远远超出了git的范围.

You can't. Git deleted the files. They are gone. You can maybe undelete them with some file recovery tool, but that's well beyond the scope of git.

不频繁进行排序会破坏使用VCS的目的.

Not committing frequently sorta defeats the purpose of using a VCS.

edit:我拿回去了! Git很棒,可能已经为您的文件造了一个斑点(我认为是为了使用git-status检查新鲜度).

edit: I take it back! Git is amazing and might have made a blob for your files (I assume for the purposes of checking freshness with git-status).

此线程建议使用git fsck --lost-found查找不是还不是存储库的一部分.它将一堆文件转储到.git/lost-found/other中;运气好的话,有些将是您的工作. (这是完成与git prune -n相同的事情的一种更简单的方法,如下所述,并且在此答案中.)

This thread suggests using git fsck --lost-found to find git objects that aren't yet part of the repository. It'll dump a bunch of files into .git/lost-found/other; with any luck some will be your work. (This is a somewhat easier way to accomplish the same thing as git prune -n, mentioned below and in this answer.)

这篇关于Git不小心删除了我所有的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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