A surprising way to lose your file in Git
We make a new directory, initialize a Git repo there:
$ mkdir git-test
$ cd git-test
git-test$ git init
Initialized empty Git repository in /home/kaz/git-test/.git/
Now we create a file and stage it for addition: git-test$ echo content > file
git-test$ git add file
We can see it in the dir listing, of course: git-test$ ls
file
And see the diff between the stage and the index, which adds the file: git-test$ git diff --cached
diff --git a/file b/file
new file mode 100644
index 0000000..d95f3ad
--- /dev/null
+++ b/file
@@ -0,0 +1 @@
+content
Now, we do a git reset --hard to eliminate the staging: git-test $ git reset --hard
Where is the working file? git-test $ ls
git-test $
Oops!