Leonardo Alves Machado
Leonardo Alves Machado

Reputation: 2837

Pull request reverted

In my repository, there was a pull request (183, from branch A) that I merged (in github's page) by mistake. I noticed in the same moment, so I pressed the button revert on github's page and it generated another pull request, in my name, id: 184 (branch Revert-A). So thinking it would fix things, I accepted my PR.

However, the branch A is under validation and probably will be soon integrated with the main branch as is. So, I tried to reopen the PR, picking branch A and opening a new PR. However I'm getting the message:

There isn’t anything to compare.

Probably because all changes on branch A are already on the history of the master branch, and the Revert-A, instead of just undoing my merge, created a new commit undoing what was done on branch A.

I wonder how can I undo my mistake. Should I rebase branch A and try to create a new PR? Or maybe try to reset the head? What would be the best option (or at least one that would actually fix my mess)?

Upvotes: 1

Views: 799

Answers (1)

Igor
Igor

Reputation: 34011

When you revert, it creates the "anti" commit of the one you're reverting. When you acceptrf commit 183, it pushed the changes to the main branch. You now need to also push 184 to revert those changes. Then you can create another revert for the revert for your PR. If you simply try to submit 183 again, that will not work as the main branch will see that the commit is (rightfully) already there, it just happens to be reverted later.

Rebasing or reseting the head on the main branch is typically not good practice, as it would mess with anyone's local repos when they try to fetch the remote.

Upvotes: 1

Related Questions