Revert to local commit?

This will reset everything to your current commit (getting rid of all changes, staged or otherwise:

git reset HEAD --hard

This will reset everything to the previous commit (also getting rid of all changes, staged or otherwise)

git reset HEAD^ --hard

the ^ next to HEAD means one commit before HEAD, HEAD being where you are currently. You can go two commits back by using ^^, or three with ^^^. Additionally you can use a tilde to specify the number of commits: ~3 for three commits back.

git reset HEAD~3 --hard

Also keep in mind that the –hard option means that these commands will throw away any changes you have that are not stashed.

Leave a Comment