gitundorevert

How do I "un-revert" a reverted Git commit?


Given a change that has been committed using commit, and then reverted using revert, what is the best way to then undo that revert?

Ideally, this should be done with a new commit, so as to not re-write history.


Solution

  • If you haven't pushed that change yet, git reset --hard HEAD^

    Otherwise, reverting the revert is perfectly fine.

    Another way is to git checkout HEAD^^ -- . and then git add -A && git commit.