Change merge strategy from 'ort' to 'recursive'
Asked Answered
T

2

1

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?

Tutelary answered 13/9, 2022 at 10:18 Comment(1)
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Sue
E
0

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.

Eshelman answered 14/9, 2022 at 4:57 Comment(1)
It is not true that you can't change it; pull.twohead is respected by git merge and the sequencer code used by revert, cherry-pick and rebase.Additional
A
0

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.

Audre answered 13/12, 2022 at 9:5 Comment(1)
Ugh, do NOT use GIT_TEST_MERGE_ALGORITHM. It could be ripped out at any time in future git releases. pull.twohead (as mentioned in a comment by philb above) is the user configuration option you can tweak to pick a different merge algorithm.Shush

© 2022 - 2024 — McMap. All rights reserved.