4 The merge mechanism (`git merge` and `git pull` commands) allows the
5 backend 'merge strategies' to be chosen with `-s` option. Some strategies
6 can also take their own options, which can be passed by giving `-X<option>`
7 arguments to `git merge` and/or `git pull`.
10 This can only resolve two heads using a 3-way merge
11 algorithm. When there is more than one common
12 ancestor that can be used for 3-way merge, it creates a
13 merged tree of the common ancestors and uses that as
14 the reference tree for the 3-way merge. This has been
15 reported to result in fewer merge conflicts without
16 causing mismerges by tests done on actual merge commits
17 taken from Linux 2.6 kernel development history.
18 Additionally this can detect and handle merges involving
19 renames. It does not make use of detected copies. This
20 is the default merge strategy when pulling or merging one
23 The 'recursive' strategy can take the following options:
26 This option forces conflicting hunks to be auto-resolved cleanly by
27 favoring 'our' version. Changes from the other tree that do not
28 conflict with our side are reflected in the merge result.
29 For a binary file, the entire contents are taken from our side.
31 This should not be confused with the 'ours' merge strategy, which does not
32 even look at what the other tree contains at all. It discards everything
33 the other tree did, declaring 'our' history contains all that happened in it.
36 This is the opposite of 'ours'; note that, unlike 'ours', there is
37 no 'theirs' merge strategy to confuse this merge option with.
40 Deprecated synonym for `diff-algorithm=patience`.
42 diff-algorithm=[patience|minimal|histogram|myers];;
43 Use a different diff algorithm while merging, which can help
44 avoid mismerges that occur due to unimportant matching lines
45 (such as braces from distinct functions). See also
46 linkgit:git-diff[1] `--diff-algorithm`. Defaults to the
47 `diff.algorithm` config setting.
53 Treats lines with the indicated type of whitespace change as
54 unchanged for the sake of a three-way merge. Whitespace
55 changes mixed with other changes to a line are not ignored.
56 See also linkgit:git-diff[1] `-b`, `-w`,
57 `--ignore-space-at-eol`, and `--ignore-cr-at-eol`.
59 * If 'their' version only introduces whitespace changes to a line,
60 'our' version is used;
61 * If 'our' version introduces whitespace changes but 'their'
62 version includes a substantial change, 'their' version is used;
63 * Otherwise, the merge proceeds in the usual way.
66 This runs a virtual check-out and check-in of all three stages
67 of a file when resolving a three-way merge. This option is
68 meant to be used when merging branches with different clean
69 filters or end-of-line normalization rules. See "Merging
70 branches with differing checkin/checkout attributes" in
71 linkgit:gitattributes[5] for details.
74 Disables the `renormalize` option. This overrides the
75 `merge.renormalize` configuration variable.
78 Turn off rename detection. This overrides the `merge.renames`
79 configuration variable.
80 See also linkgit:git-diff[1] `--no-renames`.
83 Turn on rename detection, optionally setting the similarity
84 threshold. This is the default. This overrides the
85 'merge.renames' configuration variable.
86 See also linkgit:git-diff[1] `--find-renames`.
88 rename-threshold=<n>;;
89 Deprecated synonym for `find-renames=<n>`.
92 This option is a more advanced form of 'subtree' strategy, where
93 the strategy makes a guess on how two trees must be shifted to
94 match with each other when merging. Instead, the specified path
95 is prefixed (or stripped from the beginning) to make the shape of
99 This is meant as a drop-in replacement for the `recursive`
100 algorithm (as reflected in its acronym -- "Ostensibly
101 Recursive's Twin"), and will likely replace it in the future.
102 It fixes corner cases that the `recursive` strategy handles
103 suboptimally, and is significantly faster in large
104 repositories -- especially when many renames are involved.
106 The `ort` strategy takes all the same options as `recursive`.
107 However, it ignores three of those options: `no-renames`,
108 `patience` and `diff-algorithm`. It always runs with rename
109 detection (it handles it much faster than `recursive` does), and
110 it specifically uses `diff-algorithm=histogram`.
113 This can only resolve two heads (i.e. the current branch
114 and another branch you pulled from) using a 3-way merge
115 algorithm. It tries to carefully detect criss-cross
116 merge ambiguities. It does not handle renames.
119 This resolves cases with more than two heads, but refuses to do
120 a complex merge that needs manual resolution. It is
121 primarily meant to be used for bundling topic branch
122 heads together. This is the default merge strategy when
123 pulling or merging more than one branch.
126 This resolves any number of heads, but the resulting tree of the
127 merge is always that of the current branch head, effectively
128 ignoring all changes from all other branches. It is meant to
129 be used to supersede old development history of side
130 branches. Note that this is different from the -Xours option to
131 the 'recursive' merge strategy.
134 This is a modified recursive strategy. When merging trees A and
135 B, if B corresponds to a subtree of A, B is first adjusted to
136 match the tree structure of A, instead of reading the trees at
137 the same level. This adjustment is also done to the common
140 With the strategies that use 3-way merge (including the default, 'recursive'),
141 if a change is made on both branches, but later reverted on one of the
142 branches, that change will be present in the merged result; some people find
143 this behavior confusing. It occurs because only the heads and the merge base
144 are considered when performing a merge, not the individual commits. The merge
145 algorithm therefore considers the reverted change as no change at all, and
146 substitutes the changed version instead.