1GIT-MERGE-FILE(1) Git Manual GIT-MERGE-FILE(1)
2
3
4
6 git-merge-file - Run a three-way file merge
7
9 git merge-file [-L <current-name> [-L <base-name> [-L <other-name>]]]
10 [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=<n>]
11 [--[no-]diff3] [--object-id] <current> <base> <other>
12
14 Given three files <current>, <base> and <other>, git merge-file
15 incorporates all changes that lead from <base> to <other> into
16 <current>. The result ordinarily goes into <current>. git merge-file is
17 useful for combining separate changes to an original. Suppose <base> is
18 the original, and both <current> and <other> are modifications of
19 <base>, then git merge-file combines both changes.
20
21 A conflict occurs if both <current> and <other> have changes in a
22 common segment of lines. If a conflict is found, git merge-file
23 normally outputs a warning and brackets the conflict with lines
24 containing <<<<<<< and >>>>>>> markers. A typical conflict will look
25 like this:
26
27 <<<<<<< A
28 lines in file A
29 =======
30 lines in file B
31 >>>>>>> B
32
33 If there are conflicts, the user should edit the result and delete one
34 of the alternatives. When --ours, --theirs, or --union option is in
35 effect, however, these conflicts are resolved favouring lines from
36 <current>, lines from <other>, or lines from both respectively. The
37 length of the conflict markers can be given with the --marker-size
38 option.
39
40 If --object-id is specified, exactly the same behavior occurs, except
41 that instead of specifying what to merge as files, it is specified as a
42 list of object IDs referring to blobs.
43
44 The exit value of this program is negative on error, and the number of
45 conflicts otherwise (truncated to 127 if there are more than that many
46 conflicts). If the merge was clean, the exit value is 0.
47
48 git merge-file is designed to be a minimal clone of RCS merge; that is,
49 it implements all of RCS merge's functionality which is needed by
50 git(1).
51
53 --object-id
54 Specify the contents to merge as blobs in the current repository
55 instead of files. In this case, the operation must take place
56 within a valid repository.
57
58 If the -p option is specified, the merged file (including
59 conflicts, if any) goes to standard output as normal; otherwise,
60 the merged file is written to the object store and the object ID of
61 its blob is written to standard output.
62
63 -L <label>
64 This option may be given up to three times, and specifies labels to
65 be used in place of the corresponding file names in conflict
66 reports. That is, git merge-file -L x -L y -L z a b c generates
67 output that looks like it came from files x, y and z instead of
68 from files a, b and c.
69
70 -p
71 Send results to standard output instead of overwriting <current>.
72
73 -q
74 Quiet; do not warn about conflicts.
75
76 --diff3
77 Show conflicts in "diff3" style.
78
79 --zdiff3
80 Show conflicts in "zdiff3" style.
81
82 --ours, --theirs, --union
83 Instead of leaving conflicts in the file, resolve conflicts
84 favouring our (or their or both) side of the lines.
85
87 git merge-file README.my README README.upstream
88 combines the changes of README.my and README.upstream since README,
89 tries to merge them and writes the result into README.my.
90
91 git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345
92 merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses
93 labels a and c instead of tmp/a123 and tmp/c345.
94
95 git merge-file -p --object-id abc1234 def567 890abcd
96 combines the changes of the blob abc1234 and 890abcd since def567,
97 tries to merge them and writes the result to standard output
98
100 Part of the git(1) suite
101
102
103
104Git 2.43.0 11/20/2023 GIT-MERGE-FILE(1)