Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "git reset --hard" the same as "git reset --hard HEAD"?

In order to revert changes in a working tree and index, this answer (https://stackoverflow.com/a/5812972/8278160) suggests that one run the following:

git reset --hard

Would running this be the same as running git reset --hard HEAD?

like image 297
Gokhan Avatar asked Aug 05 '17 01:08

Gokhan


People also ask

What is the difference between git reset and git reset -- hard?

Other than that, it will not bring about any changes to your index, nor will it change your current working directory. So, in short, we can say that “git reset” is a command, whereas “git reset –hard” is its variation that is used when you want to wipe out all the traces of your last commit.

What is git reset head?

The git reset HEAD~2 command moves the current branch backward by two commits, effectively removing the two snapshots we just created from the project history. Remember that this kind of reset should only be used on unpublished commits.

What is git reset types of reset?

git reset --soft , which will keep your files, and stage all changes back automatically. git reset --hard , which will completely destroy any changes and remove them from the local directory.

What is the use of git reset -- hard?

"pull" has not made merge commit, so git reset --hard which is a synonym for git reset --hard HEAD clears the mess from the index file and the working tree. Merge a topic branch into the current branch, which resulted in a fast-forward.


1 Answers

Yes, HEAD is implied if not specified, so it's the same thing.

Source [bullet item #2]

like image 164
jhpratt Avatar answered Oct 02 '22 19:10

jhpratt