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?
-
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. – YesThatIsMyName Sep 13 '22 at 11:22
2 Answers
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.

- 505
- 5
- 14
-
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. – Elijah Newren Jan 23 '23 at 23:12
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.

- 448,244
- 59
- 642
- 775
-
2It is not true that you can't change it; [`pull.twohead`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-pulltwohead) is respected by [`git merge`](https://github.com/git/git/blob/a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1/builtin/merge.c#L634-L635) and the [sequencer code](https://github.com/git/git/blob/a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1/sequencer.c#L249-L261) used by `revert`, `cherry-pick` and `rebase`. – philb Jan 12 '23 at 16:15