Michael Larionov
Michael Larionov

Reputation: 480

Reorder commits one of which is a merge

I would like to reorder two commits, one of which is a merge. So I would like to go from:

A
|\
B \
|  \
C   D

to

B
|
A
|\
C D

Is it possible and safe? Commits C and D have already been pushed, but A and B have not. git rebase -i seems to make each commit having one parent only...

Upvotes: 4

Views: 1435

Answers (1)

Paul
Paul

Reputation: 13238

This should work:

git reset --hard C
git merge D
git cherry-pick B

Upvotes: 4

Related Questions