6 ms·
The git init already made a commit of the initial empty tree. That's where your HEAD is currently pointing. You staged a file and then ran git reset --hard. Tha
by taylodl 4y ago
The git init already made a commit of the initial empty tree. That's where your HEAD is currently pointing. You staged a file and then ran git reset --hard. That took you back to your initial commit that was created by git init.
- kazinator 4y agoYour claim is not correct. $ git init Initialized empty Git repository in /home/kaz/junk/gittest/.git/ $ echo content > file $ git add file $ git commit -m first-commit-not-second [master (root-commit) 2bf5805] first-commit-not-second 1 file changed, 1 insertion(+) create mode 100644 file OK, now let's reset the file to the previous commit, to stage a change which removes it from that commit: $ git reset HEAD^ -- file fatal: Failed to resolve 'HEAD^' as a valid tree. There is no commit made by git init. The above reset would work if there was a commit before HEAD. Git apologists will say anything to defend its traps and pitfalls.