Name

merge

Synopsis

merge [options] [diff3 options]file1 file2 file3

Perform a three-way merge of files (via diff3) and place changes in file1. file2 is the original file. file1 is the “good” modification of file2. file3 is another, conflicting modification of file2. merge finds the differences between file2 and file3, and then incorporates those changes into file1. If both file1 and file3 have changes to common lines, merge warns about overlapping lines and inserts both choices in file1. The insertion appears as follows:

    <<<<<<< file1
                     lines from file1
    ========
    lines from file3
    >>>>>>>file3

You’ll need to edit file1 by deleting one of the choices. merge exits with a status of 0 (no overlaps), 1 (some overlaps), or 2 (unknown problem). See also rcsmerge.

merge accepts the -A, -e, and -E options for diff3, and simply passes them on, causing diff3 to perform the corresponding kind of merge. See the entry for diff3 in Chapter 2 for details. (The -A option is for the GNU version of diff3.)

Options

-L label

This option may be provided up to three times, supplying different labels in place of the filenames file1, file2, and file3, respectively.

-p

Send merged version to standard output instead of to file1.

-q

Produce overlap insertions but don’t warn about them.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.