user1432980 user1432980 - 3 years ago 147
Git Question

move one commit to the top of all commits

I've made a commit,

CM
, and then applied several patches,
P1
and
P2
.
So my history looks like

C1-C2-CM-P1-P2


where
C1
and
C2
are two previous commits.

The problem is that I forgot to create patch for my commit.
How to move my commit
CM
to the top of the commits? The history should look like

C1-C2-P1-P2-CM

Answer Source

If you haven't push your branch yet, you can do an interactive rebase:

git rebase -i C2

You can then reorder your commits as P1-P2-CM, and re-apply them on top of C2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download