Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - rollback to a previous commit

Tags:

git

I committed my work (note not pushed) in a known good state. I have since made unwanted local changes (without committing or pushing them). What is the command to undo these changes and revert to my previous commit state?

Please accept my apologies for the beginner question but the suggestions turned up by my googling seem arcane and I would like to be confident in my actions.

like image 555
Ben Aston Avatar asked Dec 10 '10 09:12

Ben Aston


1 Answers

From Pro Git Commnuity book:

Fixing mistakes

If you've messed up the working tree, but haven't yet committed your mistake, you can return the entire working tree to the last committed state with

$ git reset --hard HEAD

like image 56
Dan Grossman Avatar answered Sep 18 '22 07:09

Dan Grossman