tags:

views:

51

answers:

2

I'm a bit new to the whole rebasing feature within git. Let's say that I made the following commits:

A -> B -> C -> D

Afterwards, I realize that D contains a fix which depends on some new code added in A, and that these commits belong together. How do I squash A & D together and leave B & C alone?

+6  A: 

You can run git rebase --interactive and reorder D before B and squash D into A.

Rudi
+1  A: 

$ git checkout master

$ git log --oneline

D
C
B
A

$ git rebase --onto HEAD^^^ HEAD^

$ git log --oneline

D
A
Cotton
I think you mean `--oneline`? And it looks like you've dropped `C` and `B`, which isn't what the OP was intending.
bstpierre