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.
You can use this with Git v1.7.3 or later versions.
git rebase --strategy-option theirs ${branch} # Long option
git rebase -X theirs ${branch} # Short option
(which is a short for git rebase --strategy recursive --strategy-option theirs ${branch}
as stated by the documentation)
From Git v1.7.3 Release Notes:
git rebase --strategy <s>
learned the --strategy-option
/-X
option to pass extra options that are understood by the chosen merge strategy.
NB: "Ours" and "theirs" mean the opposite of what they do during a straight merge. In other words, "theirs" favors the commits on the current branch.