Issues and pull requests / Pull requests
Revert a merge that broke something
A merged pull request broke the base branch. You want its changes out of the base branch, through a normal pull request.
2 min read
You need write access.
1. Open the revert pull request
On the web:
- Open the merged pull request.
- In the box This pull request is merged, click Revert.
- In the dialog, click Revert.
In a terminal:
src pr revert 7
The forge makes a new branch from the base branch, with a commit that undoes the pull request. Then it opens a pull request from that branch.
For a pull request that merged by rebase, that one commit undoes every commit that the rebase put on the base branch. A git server that cannot do this yet refuses the revert, and the reason gives the git revert command that does it.
src pr revertprints the URL of the new pull request.--draftopens it as a draft.--titleand--bodyset its text.
2. Merge the revert
Merge the new pull request as any other. See Merge a pull request when its checks pass.
Done
The changes of the broken pull request left the base branch. One more pull request undid them.
Later: REST and MCP
An agent or a script does the same work over REST or MCP, with the same rules. The REST paths are under /api/v1/repos/{owner}/{repo}.
| You want to | REST | MCP tool |
|---|---|---|
| Revert a merged pull request | POST /pulls/{n}/revert, with { "title", "body", "draft" } | revert_pull |