There is project A, in which there are files: file1, file2. There is a project B with the same files file1, file2, but with different content. I want to combine the files: file1 of project A with file1 of project B and file file2, respectively. How can I do that? (you need to do something like manual conflict resolution)

  • and the content of the project is ideologically the same? - korytoff
  • 2
    the merge operation is performed not for files, but for commits. you probably will help the program diff - aleksandr barakin

1 answer 1

You can use the diff program directly.

example.

$ cat f1 1 2 3 $ cat f2 1 x 3 $ diff -u f1 f2 --- f1 2018-05-26 00:32:56.545662873 +0300 +++ f2 2018-05-26 00:33:13.369761319 +0300 @@ -1,3 +1,3 @@ 1 -2 +x 3 

if you want the output to look “like manual conflict resolution”:

 $ diff --changed-group-format="<<<<<<<%c'\012'%<=======%c'\012'%>>>>>>>>%c'\012'" f1 f2 1 <<<<<<< 2 ======= x >>>>>>> 3