Git: how revert branch merge without overwriting history?

You might be looking for git-revert which exist exactly for reverting changes you already published. Reverting a merge commit is a special case which needs some additional thought: git revert applied to a merge commit only reverts the changes introduced by the merge commit, but not the merge itself. So special measures need to be taken, so that you can merge your branch again after it was fixed.

This is described in great detail in revert-a-faulty-merge.

You might be looking for git-revert, which exist exactly for reverting changes you already published. Reverting a merge commit is a special case which needs some additional thought: git revert applied to a merge commit only reverts the changes introduced by the merge commit, but not the merge itself. So special measures need to be taken, so that you can merge your branch again after it was fixed.

This is described in great detail in revert-a-faulty-merge.

1 for actually reading the question (as opposed to what I did). :-) – Aasmund Eldhuset Mar 21 at 21:51.

Edit: This turns out not to be what the OP asked for, but I'll keep it here in case someone should happen to look for a solution that does involve rewriting history. First, create a new branch if you want to keep the merge commit locally, so that the commit doesn't "disappear" after you move master: git branch erroneousMerge master If the other developers have also made commits after the erroneous merge, they must do this as well! Then, reset master to refer to the last commit before the merge; let's say that it's commit e498b2...: git checkout e498b2 git branch -f master Now, you can push the corrected master (-f indicates that you want to make the server reset its master branch to the commit that you have made it point to, even though this commit is an ancestor of the one it points to in the repository): git push -f origin master Now, the other developers can update their master to match that of the server(-f indicates that they accept that the branch has moved backwards): git fetch -f origin master:master If the other developers have made changes after the erroneous merge (let's say that the merge commit is abc123, they can use rebase to move the changes to the corrected master: git rebase --onto master abc123 oldMaster If you screw up at some point and end up with "losing" commits because there is no longer any branches pointing to them, you can use git fsck --lost-found to recover them.

What you are suggesting is exactly overwriting history. I would like to avoid this, because there are too many people who are using repository and all of them will have to perform this operation. I am sure there is a better way.

– Sergiy Byelozyorov Mar 21 at 21:18 You could create a new commit that reverses the effects of the merge commit by using git revert (also described in the link @cebewee posted). – Aasmund Eldhuset Mar 21 at 21:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions