0

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
  • 3
    It defaults to HEAD if a tree/commit is not provided. git-scm.com/docs/git-reset#_description Commented Jan 24, 2020 at 3:57
  • @JeffMercado In other words, yes, git reset --hard HEAD=git reset --hard. Of course, when I say git reset --hard I mean that after that the Enter key is pressed (no tree/commit provided). Commented Jan 24, 2020 at 4:03

2 Answers 2

2

git reset man page is clear:

The <tree-ish>/<commit> defaults to HEAD in all forms.

That is from git v1.7.2.3, commit 7b8cd49, July 2010

Sign up to request clarification or add additional context in comments.

Comments

1

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

By "to a previous commit", do you mean "to the latest previous commit"?
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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.