Assuming you have permissions on repo A to do that, you can rewrite the history of its master
and remove all the wrong merged commits.
For example, if repository A had a clean history up to commit1, then the PR got merged so the rest of the history contains commits from that wrong PR, but also "good" commits from other PRs, then in that repo:
git checkout master && git pull # be sure to work with the latest
git rebase -i commit1
That will open your favorite editor showing one commit per line. Remove all the lines corresponding to "bad" commits (including any merge commit from that PR) and keep the "good" ones. Save and exit.
If conflicts happen (somebody based their work on something from that PR), you'll need to manually fix it and then git rebase --continue
.
Once the rebase is done, you have the branch history clean as if the PR was never merged. But, and here's where you need permission to do this, you need to republish it in the remote with git push -f origin master
and make sure to report it to anybody who may have checked out the old wrong version of it (they would have to delete+create the repo, or the branch, or if they had actually done some work on top of it they should probably delete+create the branch anyway and use stash or cherry-pick to reproduce the work on top of it).
If no "good" commits have been mixed with "bad" ones, then the solution is much simpler. For example, if repository A had a clean history up to commit1 and then everything else is "wrong", you can just reset the branch to that last good commit:
git checkout master && git pull
git reset --hard commit1
git push -f origin master
Again, you need write permissions for the branch master
and warn anybody who may have based their work on it.