How to restore files that were removed by git?

Posted by Ryan on Stack Overflow See other posts from Stack Overflow or by Ryan
Published on 2010-05-06T10:41:18Z Indexed on 2010/05/06 10:48 UTC
Read the original article Hit count: 127

Filed under:

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?

© Stack Overflow or respective owner

Related posts about git