8

What is the difference between the git merge option --strategy-option (short -X) and --strategy (short -s)?

There are a lot of questions regarding merge strategies. But none explain the difference between these options.

Also the git documentation is not helpful:

--strategy-option Pass merge strategy specific option through to the merge strategy.

Matthias M
  • 12,906
  • 17
  • 87
  • 116
  • A strategy option is like a sub strategy. Taking `recursive` for example, two of its options are `ours` and `theirs`. One option makes the strategy works in a specific way. – ElpieKay Dec 11 '17 at 13:17

2 Answers2

12

TL;DR: -s is for specifying a merge strategy -X is for supplying options for said strategy.

The git documentation says:

-s <strategy>
--strategy=<strategy>

Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no -s option, a built-in list of strategies is used instead (git merge-recursive when merging a single head, git merge-octopus otherwise).

-X <option>
--strategy-option=<option>

Pass merge strategy specific option through to the merge strategy.

Additionally, further down the chapter MERGE STRATEGIES explains all the available strategies and their options.

aPhilRa
  • 157
  • 1
  • 8
  • 3
    I like to say that `-X` stands for `eXtend`, as in *add more options to the strategy you choose.* Essentially, I believe that the *names* "strategy" and "strategy-option" are inherently confusing, but "strategy" and "eXtended option *to/for* strategy" are at least a little bit less so. – torek Dec 11 '17 at 16:12
0

The merge allows the backend 'merge strategies' to be chosen with -s option. Some strategies can also take their own options, which can be passed by giving -X arguments to 'git-merge' and/or 'git-pull'.

On a very high level, the following are supported in the strategy option from 1.7

  • resolve
  • recursive
    • ours
    • theirs
    • subtree[=path]
  • octopus
  • ours
  • subtree

For details refer to the documentation

Srini V
  • 11,045
  • 14
  • 66
  • 89