36 | Reverting Commits |
Sometimes we make mistakes. A commit that wasnât supposed to be
shared gets pushed to a public repository, a commit has a bug that
canât be fixed and needs to be undone, or maybe you just donât need
that code any longer. These cases all call for git
revert
.
The git revert
command does just what
you might expect. It reverts a single commit by applying a reverse
commit to the history.
You can call git revert
with just a
commit ID. Git launches the editor with the commit message already
filled out. It follows this pattern:
 | ââRevert "some commit message"â â |
 | âââ â |
 | ââThis reverts commit <some commit hash>.â â |
You can edit this message to be whatever you want. You can ...
Get Pragmatic Guide to Git now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.