Change merge strategy from 'ort' to 'recursive'

2.9k Views Asked by At

I don't know how, but default merge strategy is ort in my pc, but I want to change that to recursive. I referred some online sources but none of them were useful. Can someone tell me how can I change my default merge strategy?

2

There are 2 best solutions below

1
On

TLDR; set environment variable GIT_TEST_MERGE_ALGORITHM=recursive

Found out in the source code of git it check first for environment variable GIT_TEST_MERGE_ALGORITHM

once setting the value to recursive it change the default merge strategy. I don't think it's the cleanest solution because of the TEST in the environment variable (probably meant for testing) but it's better then nothing.

1
On

You can't:1 the default merge strategy for git merge, git cherry-pick, etc., is hard-coded.2 You can easily run git merge -s recursive, either manually or through an alias.

The -s recursive and -s ort strategies are supposed to produce the same result except when -s recursive would bail out but -s ort can succeed. If you come across cases where this isn't true, report them to the Git developers.


1For some definition of "can't" anyway: if you work hard enough at it, you certainly could. For instance, just clone Git and customize it.

2For git merge in particular, the default is octopus when giving multiple heads, and otherwise is whichever of ort or recursive it is for your particular Git version.