]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/merge-strategies.txt
diff: --ignore-cr-at-eol
[thirdparty/git.git] / Documentation / merge-strategies.txt
CommitLineData
bb73d73c
JL
1MERGE STRATEGIES
2----------------
3
3c3e6f56 4The merge mechanism (`git merge` and `git pull` commands) allows the
566c5111
JH
5backend 'merge strategies' to be chosen with `-s` option. Some strategies
6can also take their own options, which can be passed by giving `-X<option>`
3c3e6f56 7arguments to `git merge` and/or `git pull`.
566c5111 8
bb73d73c
JL
9resolve::
10 This can only resolve two heads (i.e. the current branch
4fa535a1 11 and another branch you pulled from) using a 3-way merge
bb73d73c
JL
12 algorithm. It tries to carefully detect criss-cross
13 merge ambiguities and is considered generally safe and
9688a882 14 fast.
bb73d73c
JL
15
16recursive::
4fa535a1
WC
17 This can only resolve two heads using a 3-way merge
18 algorithm. When there is more than one common
19 ancestor that can be used for 3-way merge, it creates a
9688a882 20 merged tree of the common ancestors and uses that as
bb73d73c
JL
21 the reference tree for the 3-way merge. This has been
22 reported to result in fewer merge conflicts without
13f72a1d 23 causing mismerges by tests done on actual merge commits
bb73d73c
JL
24 taken from Linux 2.6 kernel development history.
25 Additionally this can detect and handle merges involving
9688a882
JH
26 renames. This is the default merge strategy when
27 pulling or merging one branch.
566c5111
JH
28+
29The 'recursive' strategy can take the following options:
30
31ours;;
32 This option forces conflicting hunks to be auto-resolved cleanly by
33 favoring 'our' version. Changes from the other tree that do not
34 conflict with our side are reflected to the merge result.
a944af1d 35 For a binary file, the entire contents are taken from our side.
566c5111
JH
36+
37This should not be confused with the 'ours' merge strategy, which does not
38even look at what the other tree contains at all. It discards everything
39the other tree did, declaring 'our' history contains all that happened in it.
40
41theirs;;
a944af1d 42 This is the opposite of 'ours'.
566c5111 43
58a1ece4
JF
44patience;;
45 With this option, 'merge-recursive' spends a little extra time
46 to avoid mismerges that sometimes occur due to unimportant
47 matching lines (e.g., braces from distinct functions). Use
48 this when the branches to be merged have diverged wildly.
49 See also linkgit:git-diff[1] `--patience`.
50
4db4f0fb
JK
51diff-algorithm=[patience|minimal|histogram|myers];;
52 Tells 'merge-recursive' to use a different diff algorithm, which
53 can help avoid mismerges that occur due to unimportant matching
54 lines (such as braces from distinct functions). See also
55 linkgit:git-diff[1] `--diff-algorithm`.
56
4e5dd044
JF
57ignore-space-change;;
58ignore-all-space;;
59ignore-space-at-eol;;
e9282f02 60ignore-cr-at-eol;;
4e5dd044
JF
61 Treats lines with the indicated type of whitespace change as
62 unchanged for the sake of a three-way merge. Whitespace
63 changes mixed with other changes to a line are not ignored.
e9282f02
JH
64 See also linkgit:git-diff[1] `-b`, `-w`,
65 `--ignore-space-at-eol`, and `--ignore-cr-at-eol`.
4e5dd044
JF
66+
67* If 'their' version only introduces whitespace changes to a line,
68 'our' version is used;
69* If 'our' version introduces whitespace changes but 'their'
70 version includes a substantial change, 'their' version is used;
71* Otherwise, the merge proceeds in the usual way.
72
7610fa57
JN
73renormalize;;
74 This runs a virtual check-out and check-in of all three stages
75 of a file when resolving a three-way merge. This option is
76 meant to be used when merging branches with different clean
77 filters or end-of-line normalization rules. See "Merging
78 branches with differing checkin/checkout attributes" in
79 linkgit:gitattributes[5] for details.
80
81no-renormalize;;
82 Disables the `renormalize` option. This overrides the
83 `merge.renormalize` configuration variable.
84
d2b11eca
FGA
85no-renames;;
86 Turn off rename detection.
87 See also linkgit:git-diff[1] `--no-renames`.
88
1b47ad16 89find-renames[=<n>];;
83837ec0
FGA
90 Turn on rename detection, optionally setting the similarity
91 threshold. This is the default.
1b47ad16
FGA
92 See also linkgit:git-diff[1] `--find-renames`.
93
10ae7526 94rename-threshold=<n>;;
1b47ad16 95 Deprecated synonym for `find-renames=<n>`.
10ae7526 96
62b4698e 97subtree[=<path>];;
566c5111
JH
98 This option is a more advanced form of 'subtree' strategy, where
99 the strategy makes a guess on how two trees must be shifted to
100 match with each other when merging. Instead, the specified path
101 is prefixed (or stripped from the beginning) to make the shape of
102 two trees to match.
bb73d73c
JL
103
104octopus::
4fa535a1
WC
105 This resolves cases with more than two heads, but refuses to do
106 a complex merge that needs manual resolution. It is
bb73d73c
JL
107 primarily meant to be used for bundling topic branch
108 heads together. This is the default merge strategy when
4fa535a1 109 pulling or merging more than one branch.
bb73d73c
JL
110
111ours::
d4cbaa12
TR
112 This resolves any number of heads, but the resulting tree of the
113 merge is always that of the current branch head, effectively
114 ignoring all changes from all other branches. It is meant to
bb73d73c 115 be used to supersede old development history of side
566c5111
JH
116 branches. Note that this is different from the -Xours option to
117 the 'recursive' merge strategy.
02b00e16
MV
118
119subtree::
120 This is a modified recursive strategy. When merging trees A and
121 B, if B corresponds to a subtree of A, B is first adjusted to
122 match the tree structure of A, instead of reading the trees at
123 the same level. This adjustment is also done to the common
124 ancestor tree.
c5665000 125
126With the strategies that use 3-way merge (including the default, 'recursive'),
127if a change is made on both branches, but later reverted on one of the
128branches, that change will be present in the merged result; some people find
129this behavior confusing. It occurs because only the heads and the merge base
130are considered when performing a merge, not the individual commits. The merge
131algorithm therefore considers the reverted change as no change at all, and
132substitutes the changed version instead.