Properly revert git merge commited to origin

My branch’s history is as follows :

enter image description here

  • Git special sharing
  • Do git conflict resolution files not always represent every line in the source files?
  • git: how to push to master an unrelated repo
  • merge master to my feature branch overwrites changes in git
  • Why does Source Tree not Git Diff a Powershell Script (ps1)
  • Git: restore files stored in branch A, deleted in B
  • Now I want to revert merge with branch 558. I have it’s sha code, so I’m doing :

    git revert -m 1 1784adf300f43fb76391e92f80be01132eddb680

    and the result is :

    [master d51e2b3] Revert "Merge branch '558'"
    1 files changed, 15 insertions(+), 29 deletions(-)

    At this point when I try to push my revert back to origin, I see that only the last commit from merged 558 branch was reverted (as well as in the merge more than 1 file was affected). How can I revert all commits from the merged branch or am I doing something else wrong here.

  • How do I do the reverse of gitk's “Write commit to file”?
  • Why is it that if you download Git 2.0 from the net, you always get a 1.9.4 installer package?
  • Open Git commit editor to specific cursor location
  • How to get all remotes urls from remote git repo?
  • Atlassian “logo” after pushing to bitbucket
  • Git branch maintenance
  • One Solution collect form web for “Properly revert git merge commited to origin”

    You can specify multiple commits, commit intervals using git revert. Here, you would need to find the first commit from branch 558 which diverged from master and the commit before the merge of the two branches.

    Then, you can use:

    git revert -n {first_commit}..{last_commit}

    Here, the -n option allows not to have a commit for each reverted commit, it only stages the changes which you can commit with an appropriate description afterwards.

    It should work if your history is simple, like in your example.

    Correction and clarification: git won’t accept directly a merge commit or an interval containing a merge for a revert. It is however possible to revert an entire branch using only the merge commit and the option -m i where i denotes which side of the merge to revert (starts from 1, so here it would be 2).

    The whole issue is pretty delicate, and this document is an useful read about it.

    Git Baby is a git and github fan, let's start git clone.