]>
Commit | Line | Data |
---|---|---|
9abaa7f0 | 1 | git-merge-file(1) |
38477d9e | 2 | ================= |
9abaa7f0 JS |
3 | |
4 | NAME | |
5 | ---- | |
c3f0baac | 6 | git-merge-file - Run a three-way file merge |
9abaa7f0 JS |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
11 | [verse] | |
b1889c36 | 12 | 'git merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]] |
3a15048d | 13 | [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=<n>] |
e1068f0a | 14 | [--[no-]diff3] [--object-id] <current> <base> <other> |
9abaa7f0 JS |
15 | |
16 | ||
17 | DESCRIPTION | |
18 | ----------- | |
8077612e MÅ |
19 | Given three files `<current>`, `<base>` and `<other>`, |
20 | 'git merge-file' incorporates all changes that lead from `<base>` | |
21 | to `<other>` into `<current>`. The result ordinarily goes into | |
22 | `<current>`. 'git merge-file' is useful for combining separate changes | |
23 | to an original. Suppose `<base>` is the original, and both | |
24 | `<current>` and `<other>` are modifications of `<base>`, | |
0b444cdb | 25 | then 'git merge-file' combines both changes. |
9abaa7f0 | 26 | |
8077612e | 27 | A conflict occurs if both `<current>` and `<other>` have changes |
0b444cdb | 28 | in a common segment of lines. If a conflict is found, 'git merge-file' |
29b802aa RW |
29 | normally outputs a warning and brackets the conflict with lines containing |
30 | <<<<<<< and >>>>>>> markers. A typical conflict will look like this: | |
9abaa7f0 JS |
31 | |
32 | <<<<<<< A | |
33 | lines in file A | |
34 | ======= | |
35 | lines in file B | |
36 | >>>>>>> B | |
37 | ||
38 | If there are conflicts, the user should edit the result and delete one of | |
3a15048d | 39 | the alternatives. When `--ours`, `--theirs`, or `--union` option is in effect, |
8077612e MÅ |
40 | however, these conflicts are resolved favouring lines from `<current>`, |
41 | lines from `<other>`, or lines from both respectively. The length of the | |
3a15048d | 42 | conflict markers can be given with the `--marker-size` option. |
9abaa7f0 | 43 | |
e1068f0a | 44 | If `--object-id` is specified, exactly the same behavior occurs, except that |
45 | instead of specifying what to merge as files, it is specified as a list of | |
46 | object IDs referring to blobs. | |
47 | ||
9abaa7f0 | 48 | The exit value of this program is negative on error, and the number of |
e34f8027 JK |
49 | conflicts otherwise (truncated to 127 if there are more than that many |
50 | conflicts). If the merge was clean, the exit value is 0. | |
9abaa7f0 | 51 | |
0b444cdb | 52 | 'git merge-file' is designed to be a minimal clone of RCS 'merge'; that is, it |
2fd02c92 | 53 | implements all of RCS 'merge''s functionality which is needed by |
5162e697 | 54 | linkgit:git[1]. |
9abaa7f0 JS |
55 | |
56 | ||
57 | OPTIONS | |
58 | ------- | |
59 | ||
e1068f0a | 60 | --object-id:: |
61 | Specify the contents to merge as blobs in the current repository instead of | |
62 | files. In this case, the operation must take place within a valid repository. | |
63 | + | |
64 | If the `-p` option is specified, the merged file (including conflicts, if any) | |
65 | goes to standard output as normal; otherwise, the merged file is written to the | |
66 | object store and the object ID of its blob is written to standard output. | |
67 | ||
9abaa7f0 JS |
68 | -L <label>:: |
69 | This option may be given up to three times, and | |
70 | specifies labels to be used in place of the | |
71 | corresponding file names in conflict reports. That is, | |
b1889c36 | 72 | `git merge-file -L x -L y -L z a b c` generates output that |
9abaa7f0 JS |
73 | looks like it came from files x, y and z instead of |
74 | from files a, b and c. | |
75 | ||
76 | -p:: | |
77 | Send results to standard output instead of overwriting | |
8077612e | 78 | `<current>`. |
9abaa7f0 JS |
79 | |
80 | -q:: | |
29b802aa | 81 | Quiet; do not warn about conflicts. |
9abaa7f0 | 82 | |
67ed84f3 RT |
83 | --diff3:: |
84 | Show conflicts in "diff3" style. | |
85 | ||
ddfc44a8 EN |
86 | --zdiff3:: |
87 | Show conflicts in "zdiff3" style. | |
88 | ||
73eb40ee JH |
89 | --ours:: |
90 | --theirs:: | |
3a15048d | 91 | --union:: |
73eb40ee | 92 | Instead of leaving conflicts in the file, resolve conflicts |
3a15048d | 93 | favouring our (or their or both) side of the lines. |
73eb40ee | 94 | |
4f7fd79e AD |
95 | --diff-algorithm={patience|minimal|histogram|myers}:: |
96 | Use a different diff algorithm while merging. The current default is "myers", | |
97 | but selecting more recent algorithm such as "histogram" can help | |
98 | avoid mismerges that occur due to unimportant matching lines | |
99 | (such as braces from distinct functions). See also | |
100 | linkgit:git-diff[1] `--diff-algorithm`. | |
9abaa7f0 JS |
101 | |
102 | EXAMPLES | |
103 | -------- | |
104 | ||
5d2fc913 | 105 | `git merge-file README.my README README.upstream`:: |
9abaa7f0 JS |
106 | |
107 | combines the changes of README.my and README.upstream since README, | |
108 | tries to merge them and writes the result into README.my. | |
109 | ||
5d2fc913 | 110 | `git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345`:: |
9abaa7f0 JS |
111 | |
112 | merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels | |
113 | `a` and `c` instead of `tmp/a123` and `tmp/c345`. | |
114 | ||
e1068f0a | 115 | `git merge-file -p --object-id abc1234 def567 890abcd`:: |
116 | ||
117 | combines the changes of the blob abc1234 and 890abcd since def567, | |
118 | tries to merge them and writes the result to standard output | |
119 | ||
9abaa7f0 JS |
120 | GIT |
121 | --- | |
9e1f0a85 | 122 | Part of the linkgit:git[1] suite |