It must be very obvious, but I found no way to do it. Every manual describes rebasing onto a top of existing branch or simple interactive rebase and that's all. Suppose, I have a diamond-shaped git history like that:
* 949430f Merge commit (D) (HEAD, mybranch)
|\
| * e6a2e8b (C)
* | 3e653ff (B)
|/
* 9c3641f Base commit (A)
and i want to archieve history like:
* 949430f Combined commit (BCD)
|
* 9c3641f Base commit (A)
Commits B and C may be melted or discarded at all, doesn't matter, I want to preserve only the result. Also I DO NOT want to revert commits because of nasty conficts resolving.
Here things I've tried:
1) I can't archeve that by simple squashing B and C
git rebase -i HEAD~2
...
p 3e653ff (B)
f e6a2e8b (C)
...
Could not apply a91f3a4
Well, that's somewhat understandable, there're some conflicts.
2) I can't archeve that by squashing.
git rebase -i -p HEAD~3
...
pick 9c3641f Base commit (A)
f 3e653ff (B)
f e6a2e8b (C)
pick 949430f Merge commit (D)
...
error: unable to match a91f3a4...
3) I can't even discard B and C
git rebase -i -p -m HEAD~3
...
pick 9c3641f Base commit (A)
#pick 3e653ff (B)
#pick e6a2e8b (C)
pick 949430f Merge commit (D)
...
error: Commit 949430f is merged but option -m is not set.
fatal: cherry-pick failed
Could not pick 4f3e6231b5cecf57434613ca3afd2a21ba375eb9
Why? Here is option "-m"...
Does anyone know how to solve this problem?