Git Revert a Revert for a Merge

The error which you see is artificial check of github, which I personally find unneeded. You can revert the revert locally then:

git fetch origin master
git checkout origin/master (or reset)
git revert <REVERT HASH>
git push origin master

This should succeed, modulo conflicts with changes done since the revert.

PS: actually, the error could be because of the conflicts.


What you can try is:

  • reset (git reset --hard old_commit) that PR branch to the commit you want to revert to (the one that was reverted)
  • force push (git push --force) that branch: that will update the PR

That way, the PR is done again with the old commit.

This is a merge commit. The PR is already closed and merged.

In that case, if you have fetch that old PR branch, you can do:

  • a git log on it (git log origin/old_pr_branch)
  • a new branch from the old SHA1 commit representing the content you now want

    git checkout -b new_pr_branch old_sha1
    
  • a push to origin

    git push -u origin new_pr_branch

You can then make a new PR from that new branch, with the right content.