Take the 2-minute tour ×

by now, I know that there is a nice way how to combine commits and change the commit message by using 'git rebase --interactive'

Having the following situation:

$ git rebase --interactive HEAD^^^^
pick 5b7c140 commitA
pick 40ffd7c commitB
pick 5e7647d commitC
pick 78bea2d commitD

Rebase [...]

Is there also a possibility to handle the following requirements:

Combining commitA and commitC and commitB and commitD to new commits cAC and cBD?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

It is possible, you can rearrange the order of the commits with interactive rebase:

pick 5b7c140 commitA
squash 5e7647d commitC
pick 40ffd7c commitB
squash 78bea2d commitD


pick 5b7c140 commitA
fixup 5e7647d commitC
pick 40ffd7c commitB
fixup 78bea2d commitD

(the difference between the two is that squash allows you to edit the commit message for the new commits, whereas fixup just throws away the second commit and leaves the preceeding pick commit message in place).

There is a possibility of rebase conflict, if your commitB and commitC change a same part of a file. Often these can be easily enough sorted out.

share|improve this answer
In my case: No conflicting files regarding these commits. Git is just great, thought I have to hold the commit order. Thanks a lot! :) –  John Rumpel Mar 14 '13 at 10:08
@John - git rebase -i is very powerful tool!!! –  FooF Mar 14 '13 at 10:09

Your Answer


