I tried revert but it kept giving me annoying conflictions.
I want something like this:
is there a simple way of doing this.
As far as I can tell from your post and comments, you want to revert
E, but keep them as history. What you can do is this:
git revert HEAD~n..HEAD
Where you replace
n with far however back from
HEAD (your current commit) the commit after
What this will do is revert every commit between
HEAD and the commit after
D in reverse order, ensuring no conflicts.
This becomes substantially more complicated when there are merge commits in that range. If there are, do something like this:
git revert -m 1 HEAD~n..HEAD
Which will prefer the first parent branch of a merge commit, and remove changes introduced by merging in other branches. Do this with great care, as it may not end up doing what you actually want.