Undo a pushed commit

Git

Safely reverse a commit that is already on remote.

Problem: A bad commit is already pushed and shared with others.

When to use: When you need a safe rollback without rewriting shared history.

Prerequisites: Clean working tree, Commit SHA

  1. 1

    Inspect recent commits

    git log --oneline -n 10
  2. 2

    Revert commit

    git revert <commit-sha>
  3. 3

    Push revert

    git push origin <branch>

Common mistakes

  • Force-pushing shared branches without coordination.

Related commands: git revert, git log

Related workflows: Recover lost commits with reflog