merge - three-way file merge
merge [-p] file1 file2 file3
merge combines two files that are revisions of a single original file.
The original file is file2, and the revised files are file1 and file3.
merge identifies all changes that lead from file2 to file3 and from
file2 to file1, then deposits the merged text into file1. If the -p
option is used, the result goes to standard output instead of file1.
An overlap occurs if both file1 and file3 have changes in the same
place. merge prints how many overlaps occurred, and includes both
alternatives in the result. The alternatives are delimited as
lines in file1
lines in file3
If there are overlaps, edit the result in file1 and delete one of the
This command is particularly useful for revision control, especially
if file1 and file3 are the ends of two branches that have file2 as a
A typical use for merge is as follows:
1. To merge an RCS branch into the trunk, first check out the
three different versions from RCS (see co(1)) and rename
them for their revision numbers: 5.2, 5.11, and 22.214.171.124.
File 126.96.36.199 is the end of an RCS branch that split off the
trunk at file 5.2.
2. For this example, assume file 5.11 is the latest version on
the trunk, and is also a revision of the "original" file,
5.2. Merge the branch into the trunk with the command:
merge 5.11 5.2 188.8.131.52
3. File 5.11 now contains all changes made on the branch and
the trunk, and has markings in the file to show all
Hewlett-Packard Company - 1 - HP-UX Release 11i: November 2000
4. Edit file 5.11 to correct the overlaps, then use the ci
command to check the file back in (see ci(1)).
merge uses the ed(1) system editor. Therefore, the file size limits
of ed(1) apply to merge.
merge was developed by Walter F. Tichy.
diff3(1), diff(1), rcsmerge(1), co(1).
Hewlett-Packard Company - 2 - HP-UX Release 11i: November 2000