Normally, you can do:
$ echo "Stanley, you must beware of the Drive bee" > file-a
$ echo "What's a Drive bee?" > file-b
$ git init .
$ git add file-b
$ git commit file-b -m "We don't know, but whatever error you make with it could be fatal."
$ git reset --hard HEAD
$ ls
file-a file-b
I think I did something really bad:
$ echo "What are you doing, you darn ?" > file-a
$ echo "Can't you see I'm trying to drive?" > file-
$ git init .
$ git add -A
$ git commit file- -m "Oh, my God! [It's] the Drive !"
$ git reset --hard HEAD
$ ls
file-
Result: all staged, but uncommitted, files deleted 0_o
git reset --hard HEAD\^
fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
Is there anything I can do to recover the file I just deleted? In other words, is it possible to restore a git repository to the condition it was before (or when) the git add -A
command was issued?