GitHub Revert Pull Request: Undo a Merged PR Safely (2026 Guide)
If a pull request is already merged and causing problems, the safest rollback is usually revert, not reset. On GitHub, the merged PR page often has a Revert button that creates a rollback PR for you.
When that button is missing, you can still revert safely with CLI. The exact command depends on how the PR was merged: merge commit, squash merge, or rebase merge.
Table of contents
1. Quick decision: which rollback path to use
| Situation | Use this | Why |
|---|---|---|
| Merged PR has a visible Revert button | GitHub UI revert flow | Fastest and review-friendly: GitHub opens a rollback PR automatically. |
| PR merged as a merge commit | git revert -m 1 <merge-hash> |
Required for merge commits because parent selection must be explicit. |
| PR merged with squash | git revert <squash-commit-hash> |
Squash creates a normal single commit; no -m needed. |
| PR merged with rebase / fast-forward | git revert --no-commit OLDEST^..NEWEST |
Rebase/ff produces multiple normal commits, so revert the range. |
revert over reset. Revert creates new commits and avoids force-push repair work for teammates.
2. Revert a merged PR in GitHub UI
- Open the merged pull request page in GitHub.
- Click Revert.
- GitHub creates a new branch and rollback pull request.
- Run CI checks, request review, then merge the rollback PR.
This keeps your audit trail clean: original PR + explicit rollback PR.
3. When the Revert button is missing
The button may be unavailable even when rollback is possible. Common reasons:
- GitHub predicts conflicts and cannot auto-generate the revert cleanly.
- The PR was squash-merged or rebased in a way that requires manual commit selection.
- The source branch or repository state changed enough that GitHub cannot infer a safe auto-revert.
If you want a dedicated checklist just for this exact scenario, use GitHub Revert Button Missing Fix Guide.
4. CLI fallback by merge type
Step 1: sync local main
git switch main
git pull --ff-only
Step 2A: PR was merged with a merge commit
# Confirm parent order
git show --no-patch --pretty=raw <merge-hash>
# Keep parent 1 (usually main), undo merged side
git revert -m 1 <merge-hash>
git push origin main
Step 2B: PR was squash-merged
git log --oneline --decorate -n 30
git revert <squash-commit-hash>
git push origin main
Step 2C: PR was rebase-merged (multiple commits)
# Revert all PR commits as one rollback commit
git revert --no-commit OLDEST^..NEWEST
git status
git diff --staged
git commit -m "Revert merged PR #123"
git push origin main
Undo the rollback if needed
git log --oneline -n 10
git revert <rollback-commit-hash>
git push origin main
5. Verification and conflict handling
Before push
git status
git log --oneline --decorate -n 8
git show --name-only HEAD
If revert stops with conflicts
# resolve files, then
git add <resolved-files>
git revert --continue
# if you need to cancel
git revert --abort
After merge/push, validate production behavior and monitor error/latency dashboards before deciding whether additional rollback commits are required.
6. FAQ
Can I revert a PR without force pushing?
Yes. Revert creates new commits. Force push is usually unnecessary for merged PR rollback.
Should I revert the PR or revert individual commits?
If you need to undo the whole PR, revert the merge/squash/range as one rollback unit. Revert individual commits only when partial rollback is intentional.
Why did git revert -m 1 fail?
Usually wrong commit type (not a merge commit), incorrect parent choice, or conflicts requiring manual resolution.
Can I re-merge the same PR branch later?
Often yes, but you may need to revert the rollback first or add fresh commits, depending on merge history.
Where can I learn the full parent-selection details?
Read Git Revert a Merge Commit for deeper -m parent guidance.
Related Resources
git revert -m and re-merge strategy.
Undo Pushed Commit Guide
Copy/paste rollback recipes for shared branches.
GitHub Pull Requests Guide
Merge strategies, branch protection, and review workflows.
Git Commands Cheat Sheet
Quick daily reference for revert, reset, restore, log, and more.