Reputation: 1053
I am trying to rebase branch A onto a rather distant branch B. I don't really care for the changes that have been made in B, all that matters is that the history of B remains intact and the final checked out result of the rebase (branch A' of which B will be an ancestor) looks exactly like A.
What I tried is
git rebase B -s recursive -X theirs
Which seems to automatically resolve quite a few conflicts but unfortunately not all of them. I would really like to avoid having to step through all the conflicts manually as there are quite a lot of commits in between and the resolution is always trivial.
Is there a git command that achieves this?
Upvotes: 1
Views: 735
Reputation: 15189
I'm not sure a rebase is appropriate here. If you basically want to ignore anything that B does but incorporate it into the timeline, where would the point be that undoes B's changes? You cannot do this on a commit by commit basis (which is what a rebase does) because each commit would end up empty. A possible solution would be to just revert anything that B introduced and rebase on that.
Lets assume the history is
---X---o---A
\
o---o---B
Create the commit that reverts anything that B did since branching off at X:
git revert A..B
# same as git revert X..B
resulting in
---X---o---A
\
o---o---B---B'
where B' is equivalent to X. Now the rebase
git rebase B' A
should work without any conflict resulting in a linear history
---X o---A'
\ /
o---o---B---B'
Upvotes: 2
Reputation: 30269
When you're in each conflicted step, you can do
git checkout --ours [filename optionally]
(Counter intuitive, I know! Check this writeup for more info)
and then follow up with the usual
git rebase --continue
Upvotes: 0