TIL: How to undo published git commits

Published 2015-07-13 by muhh

Sometimes you need to jump back in your git history to an old state. Most of the times you already published your commits to other remotes so a git reset --hard $OLD_COMMIT is not a solution.

This is where git revert comes in handy.

If you want to jump back to a specific commit id 48b616601cab02df84297dcf7246d17072ac32fb all you have to do is

git revert -n 48b61660..HEAD

Now check everything and create a new commit that reverts everything from the old state to the current.

Previous

Index

Next