DEV Community

Discussion on: Why I Love: git reset --hard

Collapse
 
lico profile image
SeongKuk Han

picked up the reflog command, thanks!

Collapse
 
namanvashistha profile image
Naman Vashistha

Thanks! Yeah, reflog is super useful.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

In most cases, you don't need it. git reset "HEAD@{1}" will take you back to the last state of HEAD (increase the number if HEAD has changed since resetting), and you can even do fancy things like git reset 'main@{yesterday noon}'.

The same syntax works basically everywhere a commit hash would work, so it's also easy to check what commit you're resetting to: git show 'main@{12:00}' or git log -1 'HEAD@{5 days ago}'

Collapse
 
namanvashistha profile image
Naman Vashistha

Thank you for sharing. @darkwiiplayer