blob: 71915a00fa472e73f5fadd2205f964919d3262db [file] [log] [blame]
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +01001git-merge-file(1)
Junio C Hamano38477d92006-12-17 00:46:35 -08002=================
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +01003
4NAME
5----
Junio C Hamanoc3f0baa2007-01-18 15:53:37 -08006git-merge-file - Run a three-way file merge
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +01007
8
9SYNOPSIS
10--------
11[verse]
Jonathan Niederb1889c32008-06-30 01:09:04 -050012'git merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
Bert Wesarg3a150482010-03-01 22:46:28 +010013 [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=<n>]
brian m. carlsone1068f02023-11-01 19:24:19 +000014 [--[no-]diff3] [--object-id] <current> <base> <other>
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010015
16
17DESCRIPTION
18-----------
Martin Ågren80776122023-11-01 19:24:18 +000019Given three files `<current>`, `<base>` and `<other>`,
20'git merge-file' incorporates all changes that lead from `<base>`
21to `<other>` into `<current>`. The result ordinarily goes into
22`<current>`. 'git merge-file' is useful for combining separate changes
23to an original. Suppose `<base>` is the original, and both
24`<current>` and `<other>` are modifications of `<base>`,
Thomas Rast0b444cd2010-01-10 00:33:00 +010025then 'git merge-file' combines both changes.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010026
Martin Ågren80776122023-11-01 19:24:18 +000027A conflict occurs if both `<current>` and `<other>` have changes
Thomas Rast0b444cd2010-01-10 00:33:00 +010028in a common segment of lines. If a conflict is found, 'git merge-file'
Ralf Wildenhues29b802a2008-12-09 07:23:51 +010029normally outputs a warning and brackets the conflict with lines containing
30<<<<<<< and >>>>>>> markers. A typical conflict will look like this:
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010031
32 <<<<<<< A
33 lines in file A
34 =======
35 lines in file B
36 >>>>>>> B
37
38If there are conflicts, the user should edit the result and delete one of
Bert Wesarg3a150482010-03-01 22:46:28 +010039the alternatives. When `--ours`, `--theirs`, or `--union` option is in effect,
Martin Ågren80776122023-11-01 19:24:18 +000040however, these conflicts are resolved favouring lines from `<current>`,
41lines from `<other>`, or lines from both respectively. The length of the
Bert Wesarg3a150482010-03-01 22:46:28 +010042conflict markers can be given with the `--marker-size` option.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010043
brian m. carlsone1068f02023-11-01 19:24:19 +000044If `--object-id` is specified, exactly the same behavior occurs, except that
45instead of specifying what to merge as files, it is specified as a list of
46object IDs referring to blobs.
47
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010048The exit value of this program is negative on error, and the number of
Jeff Kinge34f8022015-10-28 18:44:21 -040049conflicts otherwise (truncated to 127 if there are more than that many
50conflicts). If the merge was clean, the exit value is 0.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010051
Thomas Rast0b444cd2010-01-10 00:33:00 +010052'git merge-file' is designed to be a minimal clone of RCS 'merge'; that is, it
Jonathan Nieder2fd02c92008-07-03 00:55:07 -050053implements all of RCS 'merge''s functionality which is needed by
Dan McGee5162e692007-12-29 00:20:38 -060054linkgit:git[1].
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010055
56
57OPTIONS
58-------
59
brian m. carlsone1068f02023-11-01 19:24:19 +000060--object-id::
61 Specify the contents to merge as blobs in the current repository instead of
62 files. In this case, the operation must take place within a valid repository.
63+
64If the `-p` option is specified, the merged file (including conflicts, if any)
65goes to standard output as normal; otherwise, the merged file is written to the
66object store and the object ID of its blob is written to standard output.
67
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010068-L <label>::
69 This option may be given up to three times, and
70 specifies labels to be used in place of the
71 corresponding file names in conflict reports. That is,
Jonathan Niederb1889c32008-06-30 01:09:04 -050072 `git merge-file -L x -L y -L z a b c` generates output that
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010073 looks like it came from files x, y and z instead of
74 from files a, b and c.
75
76-p::
77 Send results to standard output instead of overwriting
Martin Ågren80776122023-11-01 19:24:18 +000078 `<current>`.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010079
80-q::
Ralf Wildenhues29b802a2008-12-09 07:23:51 +010081 Quiet; do not warn about conflicts.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +010082
Ralf Thielow67ed84f2013-08-09 20:09:32 +020083--diff3::
84 Show conflicts in "diff3" style.
85
Elijah Newrenddfc44a82021-12-01 00:05:07 +000086--zdiff3::
87 Show conflicts in "zdiff3" style.
88
Junio C Hamano73eb40e2008-06-20 00:17:27 -070089--ours::
90--theirs::
Bert Wesarg3a150482010-03-01 22:46:28 +010091--union::
Junio C Hamano73eb40e2008-06-20 00:17:27 -070092 Instead of leaving conflicts in the file, resolve conflicts
Bert Wesarg3a150482010-03-01 22:46:28 +010093 favouring our (or their or both) side of the lines.
Junio C Hamano73eb40e2008-06-20 00:17:27 -070094
Antonin Delpeuch4f7fd792023-11-20 19:18:52 +000095--diff-algorithm={patience|minimal|histogram|myers}::
96 Use a different diff algorithm while merging. The current default is "myers",
97 but selecting more recent algorithm such as "histogram" can help
98 avoid mismerges that occur due to unimportant matching lines
99 (such as braces from distinct functions). See also
100 linkgit:git-diff[1] `--diff-algorithm`.
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +0100101
102EXAMPLES
103--------
104
Jeff King5d2fc912011-08-03 20:13:29 -0600105`git merge-file README.my README README.upstream`::
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +0100106
107 combines the changes of README.my and README.upstream since README,
108 tries to merge them and writes the result into README.my.
109
Jeff King5d2fc912011-08-03 20:13:29 -0600110`git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345`::
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +0100111
112 merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels
113 `a` and `c` instead of `tmp/a123` and `tmp/c345`.
114
brian m. carlsone1068f02023-11-01 19:24:19 +0000115`git merge-file -p --object-id abc1234 def567 890abcd`::
116
117 combines the changes of the blob abc1234 and 890abcd since def567,
118 tries to merge them and writes the result to standard output
119
Johannes Schindelin9abaa7f2006-12-16 12:22:18 +0100120GIT
121---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200122Part of the linkgit:git[1] suite