merge

NAME

merge - three-way file merge

SYNOPSIS

merge [-pq] [-L label1 [-L label3]] file1 file2 file3

DESCRIPTION

The merge(1) command combines two sets of changes from a base file into a single file. Suppose the original version is file2, and file1 and file3 contain nonconflicting changes to file2. The merge(1) utility incorporates all changes that lead from file2 to file3 into file1. The result goes to standard output if -p is present, and into file1 otherwise. The merge(1) utility is useful for combining separate changes to an original. Suppose file2 is the original, and both file1 and file3 are modifications of file2. In this case, merge(1) combines both changes.

An overlap occurs if both file1 and file3 have changes in a common segment of lines. On a few older hosts where diff3(1) does not support the -E option, merge(1) does not detect overlaps and merely supplies the changed lines from file3. On most hosts, if overlaps occur, merge(1) outputs a message (unless the -q option is given), and includes both alternatives in the result. The alternatives are delimited as follows:

<<<<<<< file1
lines in file1
=======
lines in file3
>>>>>>> file3

If there are overlaps, the user should edit the result and delete one of the alternatives. If the -L label1 and -L label3 options are given, the labels are output in place of the names file1 and file3 in overlap reports.

DIAGNOSTICS

Exit status is 0 for no overlaps, 1 for some overlaps, 2 for trouble.

EXAMPLE

Suppose you have the file hardware, which contains this text:

Clips	$1
Grommets   $1
Snaps	$1

At some point, you changed the price of grommets and saved this in a new file, hardware.new, which contains:

Clips	$2
Grommets   $1
Snaps	$1

You also have a sale price for screws, saved in the file hardware.sale:

Clips	$1
Grommets   $1
Snaps	$0.5

The merge(1) command results in the following output (with the -p option):

$ merge -p hardware.new hardware hardware.sale
Clips	$2
Grommets   $1
Snaps	$0.5

Without the -p option, the contents of hardware.new would be replaced by the merged text.

IDENTIFICATION

Author: Walter F. Tichy.
Revision Number: 1.7; Release Date: 1999/06/09.
Copyright © 1982, 1988, 1989 by Walter F. Tichy.
Copyright © 1990, 1991 by Paul Eggert.

SEE ALSO

diff3(1)

diff(1)

rcsmerge(1)

co(1)