I have a tree that looks like the following
B
/ \
A D
\ /
C
B and C don’t conflict. What I want is it to show in my history as A-B-C-D.
How can I do this in git? I’ve searched but I can’t find an answer I feel applies. I’m concerned to make a change because I don’t want to make things worse and I don’t know how I would undo it (is there a way to undo the last git command in git?)
If you want to test things out, simply clone your repository and play in the clone.
In your case,
Dshould just be a merge commit, which doesn’t contain much ifBandCdon’t conflict. So a simple rebase will workTry this in an empty repository:
You now have this (run
gitk --all):and you’re on
D. You can issueAnd you’re left with:
with
C'andD'identical toCandDin terms of “contents”. If you want to clean up, you can remove branchCin this example, but you’ll have to force it since that will make the originalCcommit dangle.