What is the difference between git reset --hard HEAD and git reset --hard? I think both do exactly the same and are simply synonyms, but please let me know if I am wrong. Thank you.
2 Answers
The
<tree-ish>/<commit>defaults to HEAD in all forms.
That is from git v1.7.2.3, commit 7b8cd49, July 2010
Comments
When want to revert to a previous commit then use:
git reset --hard HEAD If need to reset all mess created during revert use:
$git reset --hard <commit-id> 3 Comments
Jaime Montoya
By "to a previous commit", do you mean "to the latest previous commit"?
Jaime Montoya
When I want to revert to a previous commit, then both
git reset --hard HEAD and git reset --hard are synonyms, they do exactly the same, correct? That is my question.grg
I don't see how this answers the question comparing
git reset --hard with and without HEAD. This answer only gives two examples of git reset.
HEADif a tree/commit is not provided. git-scm.com/docs/git-reset#_descriptiongit reset --hard HEAD=git reset --hard. Of course, when I saygit reset --hardI mean that after that the Enter key is pressed (no tree/commit provided).