3
4
NAME
5
----
6
-git-merge-tree - Show three-way merge without touching index
6
+git-merge-tree - Perform merge without touching index or working tree
7
8
9
SYNOPSIS
10
--------
11
[verse]
12
-'git merge-tree' <base-tree> <branch1> <branch2>
12
+'git merge-tree' [--write-tree] <branch1> <branch2>
13
+'git merge-tree' [--trivial-merge] <base-tree> <branch1> <branch2> (deprecated)
14
15
+[[NEWMERGE]]
16
DESCRIPTION
17
-----------
16
-Reads three tree-ish, and output trivial merge results and
17
-conflicting stages to the standard output. This is similar to
18
-what three-way 'git read-tree -m' does, but instead of storing the
19
-results in the index, the command outputs the entries to the
20
-standard output.
21
-
22
-This is meant to be used by higher level scripts to compute
23
-merge results outside of the index, and stuff the results back into the
24
-index. For this reason, the output from the command omits
25
-entries that match the <branch1> tree.
18
+
19
+This command has a modern `--write-tree` mode and a deprecated
20
+`--trivial-merge` mode. With the exception of the
21
+<<DEPMERGE,DEPRECATED DESCRIPTION>> section at the end, the rest of
22
+this documentation describes modern `--write-tree` mode.
23
+
24
+Performs a merge, but does not make any new commits and does not read
25
+from or write to either the working tree or index.
26
+
27
+The performed merge will use the same feature as the "real"
28
+linkgit:git-merge[1], including:
29
+
30
+ * three way content merges of individual files
31
+ * rename detection
32
+ * proper directory/file conflict handling
33
+ * recursive ancestor consolidation (i.e. when there is more than one
34
+ merge base, creating a virtual merge base by merging the merge bases)
35
+ * etc.
36
+
37
+After the merge completes, a new toplevel tree object is created. See
38
+`OUTPUT` below for details.
39
+
40
+[[OUTPUT]]
41
+OUTPUT
42
+------
43
+
44
+For either a successful or conflicted merge, the output from
45
+git-merge-tree is simply one line:
46
+
47
+ <OID of toplevel tree>
48
+
49
+The printed tree object corresponds to what would be checked out in
50
+the working tree at the end of `git merge`, and thus may have files
51
+with conflict markers in them.
52
+
53
+EXIT STATUS
54
+-----------
55
+
56
+For a successful, non-conflicted merge, the exit status is 0. When the
57
+merge has conflicts, the exit status is 1. If the merge is not able to
58
+complete (or start) due to some kind of error, the exit status is
59
+something other than 0 or 1 (and the output is unspecified).
60
+
61
+USAGE NOTES
62
+-----------
63
+
64
+This command is intended as low-level plumbing, similar to
65
+linkgit:git-hash-object[1], linkgit:git-mktree[1],
66
+linkgit:git-commit-tree[1], linkgit:git-write-tree[1],
67
+linkgit:git-update-ref[1], and linkgit:git-mktag[1]. Thus, it can be
68
+used as a part of a series of steps such as:
69
+
70
+ NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
71
+ test $? -eq 0 || die "There were conflicts..."
72
+ NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
73
+ git update-ref $BRANCH1 $NEWCOMMIT
74
+
75
+[[DEPMERGE]]
76
+DEPRECATED DESCRIPTION
77
+----------------------
78
+
79
+Per the <<NEWMERGE,DESCRIPTION>> and unlike the rest of this
80
+documentation, this section describes the deprecated `--trivial-merge`
81
+mode.
82
+
83
+Other than the optional `--trivial-merge`, this mode accepts no
84
+options.
85
+
86
+This mode reads three tree-ish, and outputs trivial merge results and
87
+conflicting stages to the standard output in a semi-diff format.
88
+Since this was designed for higher level scripts to consume and merge
89
+the results back into the index, it omits entries that match
90
+<branch1>. The result of this second form is similar to what
91
+three-way 'git read-tree -m' does, but instead of storing the results
92
+in the index, the command outputs the entries to the standard output.
93
+
94
+This form not only has limited applicability (a trivial merge cannot
95
+handle content merges of individual files, rename detection, proper
96
+directory/file conflict handling, etc.), the output format is also
97
+difficult to work with, and it will generally be less performant than
98
+the first form even on successful merges (especially if working in
99
+large repositories).
100
101
GIT
102
---