4 ms·
> There is no "latest commit" in that example; one has not been made in that repo at all. Consider that the first real commit is to a virtual commit with hash
by sebazzz 4y ago
> There is no "latest commit" in that example; one has not been made in that repo at all.
Consider that the first real commit is to a virtual commit with hash 0000000... that contains an empty tree.
I seems perfectly logical to me. OP did a hard reset to that virtual commit 000000.
- kazinator 4y agoThat's another screwup in git. That commit does not behave like a commit. For instance, you cannot do this: git reset HEAD^ -- file # stage a file removal from the commit or say you have made two commits and want to reorder them with interactive rebase git rebase -i HEAD^^ # oops Whenever I start a new repo, I do this: git init git commit --allow-empty -m NIL to create a commit that actually serves as a "terminating nil" in the list since for unfathomable reasons, the 0 commit hash doesn't serve that purpose. You can't point at that 0 with HEAD^ to indicate "the point before this commit".
- fargle 4y agoYep, agree. I should have been more clear about the edge case of no prior commit. anytime you do a "reset --hard" files and changes in the working tree are likely to get deleted/reverted/etc. That's as consistent as it gets. You don't reset --hard unless you want that behavior.