Search code examples
gitversion-controlundorevertgit-reset

How can I commit reversal of last commit?


I've just created a huge commit. Now I want to commit the reversal of these changes.

So basically I want to have the same files in my repo as I'll have after git reset --hard HEAD~1, but I'd like to keep the history of my changes, so create a new commit instead of removing the last one.


Solution

  • You can commit the reversal of one or more commits using git-revert. For instance, to revert the most recent commit:

    git revert HEAD