Kornel Kornel - 3 months ago 14
Git Question

How do I select a merge strategy for a git rebase?

git-rebase
man page mentions
-X<option>
can be passed to
git-merge
. When/how exactly?

I'd like to rebase by applying patches with recursive strategy and theirs option (apply whatever sticks, rather than skipping entire conflicting commits). I don't want merge, I want to make history linear.

I've tried:

git rebase -Xtheirs


and

git rebase -s 'recursive -Xtheirs'


but git rejects
-X
in both cases.




git rebase -Xtheirs
works in recent versions, except tree conflicts need to be resolved manually. You need to run
git rebase -Xtheirs --continue
(with
-X
repeated) after resolving those conflicts.

Answer

You can use this with Git v1.7.3 or later versions.

git rebase -s recursive -X theirs ${branch}

From Git v1.7.3 Release Notes:

git rebase --strategy <s> learned the -X option to pass extra options that are understood by the chosen merge strategy.

Update: Edited to be clearer.

Comments