I have two branches:
Branch1: (old) A B C D E F G H (new)
Branch2: (old) A B D E F (new)
Notice that the C was dropped from Branch 2 and then G & H were added to Branch1.
I want to rebase Branch1 on Branch2, but I don't want the C to re-appear since it was dropped from Branch2. I only want to fast forward pushes to Branch1 from Branch2. C must be gone from history.
My broken approach:
git checkout Branch1
git rebase Branch2
Branch1: (old) A B D E F C G H (new)
What doesn't work:
- I don't have exact commits, I am automating the whole thing, so I can't use
git rebase --onto Branch2 F Hgit cherry-pick G H
- I only have two branch names, that's all.
I am mainly looking for some way to tell git rebase to only pick fast-forwarding commits. Is it possible?
One way would be to somehow keep track of the point in the history of
Branch1which was reviewed and either integrated or discarded, and then use it to rungit rebase --onto Branch2 <that_point> Branch1.one example could be to keep a reference to that commit, for example
git branch integration/Branch1 <F>(meaning "commit F on Branch1")when you integrate new commits on Branch2, you should update that reference. Say you include commit
Gon Branch2:git branch -f integration/Branch1 Gwhen you want to rebase Branch1 (or try to, at least), you can use that name:
if this succeeds, you should then update the "integration" reference:
or