There seem to be some similar questions already, but none of them are exactly what I want.
Let's say I have commit history like this
* xxxxxxxH (HEAD -> B) Latest commit * (more commits) * xxxxxxxG (B) More commits * xxxxxxxF Merge branch 'master' into B |\ | * xxxxxxxE (master) Another commit on master | * (more commits here) | * xxxxxxxD Commit on master * | xxxxxxxC Another commit * | (more commits here) * | xxxxxxxB First commit on branch A |/ * xxxxxxxA (master) some commit Now I want to rewrite the history of branch A, potentially merging or editing some commits, but I also want to change the first commit on branch A, and also I want to preserve merges, so that I keep the merge of master into A.
I first intuitively tried git rebase -i -p xxxxxxxB, but obviously that didn't include the xxxxxxxB commit itself. So another attempt was git rebase -i -p xxxxxxxB^ which did include that commit, but now it didn't actually to preserve merges.
Another option that looked promising was --root, but this one starts from the very first commit in the whole repository which is also not what I want.
Is there any way to do what I want?