如何恢复被git删除的文件? [英] How to restore files that were removed by git?

查看:1092
本文介绍了如何恢复被git删除的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git noob,git刚刚删除了一堆重要的文件。我怎么让他们回来?



我在本地机器上有一个回购。为了进入git,我只需右键点击我的项目文件夹并选择git bash here。这带来了主人,我做我所有的giting。



所以我有一些改变舞台,我做到了:

  git add。 

这个阶段发生了一系列变化。我注意到,我不想要其中的一些上演,所以我决定,我会试图取消everthing。我做到了这一点:

  git reset --hard HEAD ^ 

这基本上删除了我在上次提交时创建的一堆文件,并跳到提交前。



我如何获取这些文件?如果我不能通过git做到这一点有另一种方式吗?

解决方案

)。作为忏悔,我已经找到了从混帐恢复丢失的文件,最简单的方法:

 的git fsck的--lost发现的
ls .git / lost-found / other

不幸的是,文件名会丢失,但内容应该全部作为不同的文件存在。


I am a git noob and git just deleted a bunch of important files. How do I get them back?

I have a repo on my local machine. To get into git, I just right click my project folder and select "git bash here". This brings up the master where I do all my giting.

So I had some changes to stage and I did:

git add .

This staged a bunch of changes. I noticed that I didn't want some of these staged so I decided that I'd try to unstage everthing. I did this:

git reset --hard HEAD^

This basically deleted a bunch of files that I had made on the last commit and jumped to the commit before.

How do I get those files back? If I can't do it through git is there another way?

解决方案

I stand corrected regarding my original advice (see edit history). As penance, I've tracked down the simplest way to recover your lost files from git:

git fsck --lost-found
ls .git/lost-found/other

Unfortunately, the filenames are lost, but the contents should all be there as distinct files.

这篇关于如何恢复被git删除的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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