1

I'm in a local branch. I've deleted a file. It is waiting to be staged and marked "deleted." I have not ran git rm, git commit, git add, or anything else. How can I restore that file?

Andrew
  • 20,756
  • 32
  • 99
  • 177
  • 1
    Possible duplicate of [git recover deleted file where no commit was made after the delete](http://stackoverflow.com/questions/11956710/git-recover-deleted-file-where-no-commit-was-made-after-the-delete) – Andrew C Dec 09 '15 at 18:39

3 Answers3

4

A simple:

git checkout HEAD  <filename>

should do the trick

Igal S.
  • 13,146
  • 5
  • 30
  • 48
1
git checkout [filename]

OR

git checkout * <-- if you want recover all files in commit
Felipe Pincheira
  • 442
  • 1
  • 6
  • 21
0

If you prefer to use git gui, you can unstage the deleted file (clicking on the icon, thus moving it to the top part) and then use Commit - Revert Changes (CTRL+J) to get the file back.

C-Otto
  • 5,615
  • 3
  • 29
  • 62