Skip to content

Undo Git Commits

By Jasper Frumau

Undo Git Commits, how do you do these easily? Do quickly undo a few commits so you can go back a few version you can use:

git reset --hard HEAD~1

This will make your repository go back one commit or undo the last commit made.

Reset to specific Commit

If you want to go back to specific commit by number you can do:

git log --oneline

to see all the commits with id numbers and titles. Pick the commit id you want to go back to like so:

git reset --hard HEAD e323918

Pushing Changes to Repository

Once done you have to push the changes to the repo this way

git push origin master --force

voila

NB Great tips at Oh shit git.

Comments are closed for this post.