Goods
Goods

Reputation: 225

How to revert a PR when there's no revert option on Github?

A PR was accidentally merged into main before it had been properly sanitized which I think has resulted in their being no revert option. The lack of an option suggests that it is not possible/simple?

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/reverting-a-pull-request

I have write permissions to the repo in question.

Upvotes: 0

Views: 2435

Answers (1)

matt
matt

Reputation: 535737

A revert is just a commit like any other commit. So, you can certainly revert the merge commit and push that, possibly as a PR if you're not able to push directly to main.

However, note that this reverses the effect of the merge without undoing the topology. You won't be able to merge those same commits again later.

In theory you can force main to go backwards to a commit before this bad merge took place, erasing the unwanted commits since then, or force main to point directly to the commit at the end of the good branch — namely by using a hard reset. But in practice, where you're sharing this repo with others, that would be a pretty terrible idea.

Upvotes: 1

Related Questions