3

github provides a "Revert" button in it's web interface, which allow us to revert a pull request that was already merged.

This always involves, to the best of my knowledge, creating a new pull request to revert the changes.

Is it possible to replicate this functionality easily using the API? Is it possible to do it without having to create a new Pull Request?

Just to clarify more, the PR is from branch A to branch B - If I undo the changes in branch B using underlying git commands, what will happen to the PR?

mvallebr
  • 2,388
  • 21
  • 36

1 Answers1

2

There's no API endpoint to do this for you, no. What you need to do is use the SHA of the merged pull request and do a git revert SHA locally followed by a git push to the appropriate branch. That avoid needing to do a new pull request.

If I undo the changes in B using the underlying git commands, what will happen to the PR?

Nothing. It remains merged.

Ian Stapleton Cordasco
  • 26,944
  • 4
  • 67
  • 72
  • It depends, but in general it's impossible. It's always absolutely awful to do that to the other collaborators. git will not handle that well – Ian Stapleton Cordasco Jul 28 '15 at 12:35
  • My intention is not allow pull requests that haven't passed on continuous integration validations to be merged, but so far I haven't found anyway to block the merge or undo the merge easily – mvallebr Jul 28 '15 at 13:29
  • @mvallebr well you can only block a merge by closing the pull request. That doesn't prevent someone from re-opening it merge it. And when you close it CI doesn't continue to run (afaik). So it seems you have to solve the problem in a different way – Ian Stapleton Cordasco Jul 28 '15 at 21:42
  • This is the way I am currently solving it, the problem is: it generates a lot of spam because of the way github notifications work. Anyway, I will figure out a good enough solution, it's was just really worth asking, just to be sure I was not missing an option. Thanks a lot – mvallebr Jul 29 '15 at 08:50