revert: Reverting a Previous Commit

Learn how to write revert commit messages that clearly reference the original commit. Covers the revert format, when to revert vs fix, and linking to the reverted commit.

Type Examples

Detailed Explanation

The revert Commit Type

The revert type is used when you undo a previous commit. It is important that the revert message clearly references the original commit being reverted, so the commit history remains understandable.

Standard Format

Git's git revert command generates a message in this format:

Revert "feat: add user authentication"

This reverts commit abc1234.

When using Conventional Commits, adapt this to:

revert: add user authentication

This reverts commit abc1234def5678.
The OAuth provider has a critical vulnerability
(CVE-2024-XXXX) that needs to be patched first.

When to Revert

Revert a commit when:

  • The commit introduced a bug or regression
  • The feature needs to be rolled back for business reasons
  • A dependency introduced in the commit has a security issue
  • The commit broke the build or CI pipeline
  • The change needs more work before it can be shipped

revert vs fix

Use revert when... Use fix when...
You undo the entire commit You fix part of the issue
The original commit should not have been merged The original commit was correct but incomplete
You need to roll back immediately You have time to investigate and patch

Referencing the Original Commit

Always include the full commit hash or at least 7+ characters:

revert: add payment processing webhook

This reverts commit a1b2c3d4e5f6g7h8.

The webhook endpoint was receiving duplicate events
from Stripe, causing double-charges. Reverting until
idempotency handling is implemented.

Refs #987

Reverting Breaking Changes

If the original commit was a breaking change, the revert is also a breaking change (it removes the new behavior):

revert!: redesign API response format

This reverts commit f1e2d3c4b5a6.

BREAKING CHANGE: Response format reverted from
{ result, errors } back to { data, error }
pending further discussion with API consumers.

Partial Reverts

If you only need to revert part of a commit, use fix or refactor instead and explain which parts of the original commit you are undoing:

fix: remove broken OAuth provider from login

Partially reverts commit abc1234. Keeps the session
management changes but removes the Google OAuth
integration that caused login failures.

Use Case

A commit that was merged to main introduced a regression that breaks the checkout flow for all users. You need to immediately revert the commit to restore service while the root cause is investigated. Your commit message needs to clearly identify what was reverted and why.

Try It — Git Commit Message Generator

Open full tool