skip to Main Content
Undo Git Commits

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.

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top