Revert a Commit on GitHub: Web UI + Git CLI (2026 Guide)

Published February 16, 2026 · 8 min read

If a bad commit is already pushed, revert is usually the safest fix. On GitHub, you can often click Revert from the commit or PR page, then merge the generated rollback pull request.

When GitHub cannot auto-revert (usually conflicts), use CLI fallback with git revert. This guide gives both paths with copy/paste commands.

⚙ Quick links: Revert Merged PR on GitHub · GitHub Revert Button Missing Fix · GitHub Revert Conflict Resolution · Protected Branch Revert + Merge Queue · Git Revert Complete Guide · Undo Pushed Commit (quick workflow) · Revert Merge Commit (-m explained) · Undo Last Commit · Git Undo Decision Guide · Git Commands Cheat Sheet

Table of contents

  1. Quick decision: GitHub UI vs CLI
  2. Revert one commit in GitHub UI
  3. Revert a merged pull request in GitHub
  4. CLI fallback when Revert button is missing
  5. Verification and conflict handling
  6. FAQ

1. Quick decision: GitHub UI vs CLI

Situation Use this Why
One bad commit, no expected conflicts GitHub commit page Revert Fastest route: GitHub creates revert branch and PR for you.
Merged PR needs rollback GitHub PR page Revert Automatically builds a rollback PR from the merge commit.
Revert button missing or conflicts expected git revert in CLI Full control over conflict resolution and commit message.
Pushed merge commit rollback git revert -m 1 <merge-hash> Required for merge commits because parent selection is explicit.

CLI quick recipe (shared branch)

git switch main
git pull --ff-only
git revert <commit-hash>
git push origin main

CLI quick recipe (merged PR rollback)

git show --no-patch --pretty=raw <merge-hash>
git revert -m 1 <merge-hash>
git push origin main
Tip: Revert is safer than reset for pushed commits because it keeps history intact and avoids force-push recovery work for teammates.

2. Revert one commit in GitHub UI

Use this when a single commit introduced a bug and you want a PR-based rollback from the web interface.

  1. Open your repository on GitHub and navigate to the commit (for example from the commit history or a merged PR timeline).
  2. On the commit page, click Revert.
  3. GitHub creates a new branch and opens a pull request with the inverse changes.
  4. Review CI checks, request approvals if needed, then merge the revert PR.

After merge, GitHub has created a normal revert commit. No history rewrite is required.

3. Revert a merged pull request in GitHub

For rollback of a merged PR, GitHub usually shows a Revert button directly on that PR page.

  1. Open the merged PR.
  2. Click Revert.
  3. GitHub generates a new PR that reverts the merge commit.
  4. Run your normal release checks, then merge.
Warning: The Revert button can be unavailable when GitHub predicts conflicts or cannot determine a clean revert path. In that case, use the CLI workflow below.

For a dedicated diagnostic flow for this exact problem, read GitHub Revert Button Missing Fix Guide.

4. CLI fallback when Revert button is missing

Revert a normal commit by hash

git switch main
git pull --ff-only
git log --oneline --decorate -n 20
git revert <commit-hash>
git push origin main

Revert a merge commit (common for merged PR rollbacks)

# inspect parent order first
git show --no-patch --pretty=raw <merge-hash>

 # keep parent 1 (usually mainline)
git revert -m 1 <merge-hash>
git push origin main

Revert multiple commits as one rollback commit

git revert --no-commit OLDEST^..NEWEST
git status
git diff --staged
git commit -m "Revert problematic release commits"
git push origin main

If you accidentally reverted the wrong commit, use:

git revert <revert-commit-hash>
git push origin main

5. Verification and conflict handling

Before pushing

git status
git log --oneline --decorate -n 8
git show --name-only HEAD

If revert has conflicts

# resolve files manually, then:
git add <resolved-files>
git revert --continue

 # if needed, cancel:
git revert --abort

After merge or push, validate the app behavior and monitor alerts before applying additional rollback commits.

6. FAQ

Does GitHub Revert delete commit history?

No. GitHub Revert creates a new commit that inverses earlier changes, just like git revert in CLI.

Can I revert an old commit, not just the latest?

Yes. You can revert any reachable commit by hash. Older commits can produce conflicts if later commits touched the same lines.

Should I use reset instead of revert on GitHub?

Not for shared branches. git reset requires force push and rewrites history. Use git revert for pushed commits.

Why did GitHub open a PR instead of reverting directly to main?

GitHub uses a branch + PR flow to keep review and CI checks intact. Merging that PR applies the rollback safely.

Where should I learn merge revert parent selection?

Use Git Revert a Merge Commit for detailed -m parent guidance.

Related Resources

GitHub Revert Pull Request Guide Rollback merged PRs safely, including squash/rebase and missing-button cases. Revert Button Missing Fix Guide Exact checks for missing Revert buttons and safe rollback alternatives. Protected Branch Revert Guide Safe rollback workflow for protected branches and merge queue rules. Git Revert Complete Guide Deep dive on single commit, ranges, merge reverts, and conflict handling. Undo Pushed Commit Guide Fast copy/paste rollback workflow for shared branches. Revert Merge Commit Guide Understand -m parent choice before reverting merged PRs. Git Undo Decision Guide Choose reset vs revert vs restore in seconds. Git Commands Cheat Sheet Quick daily reference for revert, reset, restore, log, and more.