Situation
=========

Let's say I wanted to always rebase before merging, but noticed very late that I forgot to do so and now commit E and C have the same parent:

```
I (branch-1)
|\
| H (branch-2)
| |\
| | G
| |/
| F
| |\
| | E
| D |
| |\ \
| | |/
| |/|
| | C
| |/
B |
 \|
  A

```

I would like to "untangle" the history as such:

```
I (branch-1)
|\
| H (branch-2)
| |\
| | G
| |/
| F
| |\
| | E
| |/
| D
| |\
| | C
| |/
B |
 \|
  A

```

The only way I see is quite cumbersome and would involve a lot of successive history changing commands like `git rebase --onto ...` and `git reset --hard ...` where most of the supplied commit hashes (the `...`) would be known only half way through the process.

Question
========

Is there a more automated way to untangle the graph? Can we make a script for such a history rewrite, in which we use just the information from the initial state?