cmd:diff3 

Help 

SYNOPSIS

diff3 [options] mine older yours

Options

-E     Generate an ed script that incorporates all the changes from
       older to yours into mine, except bracket lines from
       overlapping changes' first and third files.  With -e, an
       overlapping change looks like this:
<<<<<<< mine
lines from mine
=======
lines from yours
>>>>>>> yours
-m
--merge
       Apply  the  edit script to the first file and send the result to
       standard output.  Unlike piping the output  from  diff3  to  ed,
       this  works  even  for binary files and incomplete lines.  -A is
       assumed if no edit script option is specified.
-A     Incorporate all changes from older to yours into mine, surround-
       ing all conflicts with bracket lines.
-T     Output a tab rather than two spaces before the text of a line in
       normal format.  This causes the alignment of tabs in the line to
       look normal.
--initial-tab
       Output a tab rather than two spaces before the text of a line in
       normal format.  This causes the alignment of tabs in the line to
       look normal.
-i     Generate w and q commands at the end of the ed script for System
       V  compatibility.   This option must be combined with one of the
       -AeExX3 options, and may not be combined with -m.

Usage for System V 

diff3 many-changed-file original-file less-changed-file
diff3 -E many-changed-file original-file less-changed-file > script

edit the script a little bit most important, delete the last 2 line of

w
q

Otherwise, the original file will be overwritten!!!

# backup is always recommended!
cp many-changed-file{,.sav}
cp many-changed-file file-to-change
(cat script; echo '1,$p') | ed - file-to-change > file-changed
diff -C 2 file-to-change file-changed

edit the newfile according to the diff and what we want