Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

How to revert a merge commit (that you pushed)

Tags: git


  • The merge-commit has two parents. The resultant revert-commit needs to know which parent is the mainline. This is why the --mainline option exists.
  • After reverting a merge-commit, we cannot just merge the branch again later and expect all the changes to come back.


  • Why not just checkout the earlier commit and make a new one? This will work if and only if you are reverting a continuous range of commits that starts at HEAD and ends before the earlier commit. It will not work for reverting commits at arbitrary places in the history.
  • Why not use git reset? This will rewrite public history which can create quite a pickle :)