Revert the Latest Commit

Create a new commit that undoes the last commit.

git revert HEAD

Example

git revert HEAD --no-edit

Revert a Specific Commit

Undo an older commit without rewriting history.

git revert <commit-hash>

Example

git revert 7b3a1f2

Revert Multiple Commits

Revert a range of commits in one sequence.

git revert --no-commit OLD_HASH..HEAD
git commit -m "Revert release candidate changes"

Revert a Merge Commit

Specify the parent branch when reverting a merge.

git revert -m 1 <merge-commit-hash>

Example

git revert -m 1 9ac82a4

Common mistakes / Errores comunes

  • People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
  • It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
  • Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026