Autogenerated manpages for v2.48.1-2-g75716
[git-manpages.git] / man1 / git-merge-file.1
blobbfff9c9acab08f26d26ccfd6ce39894e390edccc
1 '\" t
2 .\"     Title: git-merge-file
3 .\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
5 .\"      Date: 2025-01-13
6 .\"    Manual: Git Manual
7 .\"    Source: Git 2.48.1.2.g757161efcc
8 .\"  Language: English
9 .\"
10 .TH "GIT\-MERGE\-FILE" "1" "2025-01-13" "Git 2\&.48\&.1\&.2\&.g757161ef" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 git-merge-file \- Run a three\-way file merge
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 \fIgit merge\-file\fR [\-L <current\-name> [\-L <base\-name> [\-L <other\-name>]]]
36         [\-\-ours|\-\-theirs|\-\-union] [\-p|\-\-stdout] [\-q|\-\-quiet] [\-\-marker\-size=<n>]
37         [\-\-[no\-]diff3] [\-\-object\-id] <current> <base> <other>
38 .fi
39 .SH "DESCRIPTION"
40 .sp
41 Given three files \fI<current>\fR, \fI<base>\fR and \fI<other>\fR, \fIgit merge\-file\fR incorporates all changes that lead from \fI<base>\fR to \fI<other>\fR into \fI<current>\fR\&. The result ordinarily goes into \fI<current>\fR\&. \fIgit merge\-file\fR is useful for combining separate changes to an original\&. Suppose \fI<base>\fR is the original, and both \fI<current>\fR and \fI<other>\fR are modifications of \fI<base>\fR, then \fIgit merge\-file\fR combines both changes\&.
42 .sp
43 A conflict occurs if both \fI<current>\fR and \fI<other>\fR have changes in a common segment of lines\&. If a conflict is found, \fIgit merge\-file\fR normally outputs a warning and brackets the conflict with lines containing <<<<<<< and >>>>>>> markers\&. A typical conflict will look like this:
44 .sp
45 .if n \{\
46 .RS 4
47 .\}
48 .nf
49 <<<<<<< A
50 lines in file A
51 =======
52 lines in file B
53 >>>>>>> B
54 .fi
55 .if n \{\
56 .RE
57 .\}
58 .sp
59 If there are conflicts, the user should edit the result and delete one of the alternatives\&. When \fB\-\-ours\fR, \fB\-\-theirs\fR, or \fB\-\-union\fR option is in effect, however, these conflicts are resolved favouring lines from \fI<current>\fR, lines from \fI<other>\fR, or lines from both respectively\&. The length of the conflict markers can be given with the \fB\-\-marker\-size\fR option\&.
60 .sp
61 If \fB\-\-object\-id\fR is specified, exactly the same behavior occurs, except that instead of specifying what to merge as files, it is specified as a list of object IDs referring to blobs\&.
62 .sp
63 The exit value of this program is negative on error, and the number of conflicts otherwise (truncated to 127 if there are more than that many conflicts)\&. If the merge was clean, the exit value is 0\&.
64 .sp
65 \fIgit merge\-file\fR is designed to be a minimal clone of RCS \fImerge\fR; that is, it implements all of RCS \fImerge\fR\*(Aqs functionality which is needed by \fBgit\fR(1)\&.
66 .SH "OPTIONS"
67 .PP
68 \-\-object\-id
69 .RS 4
70 Specify the contents to merge as blobs in the current repository instead of files\&. In this case, the operation must take place within a valid repository\&.
71 .sp
72 If the
73 \fB\-p\fR
74 option is specified, the merged file (including conflicts, if any) goes to standard output as normal; otherwise, the merged file is written to the object store and the object ID of its blob is written to standard output\&.
75 .RE
76 .PP
77 \-L <label>
78 .RS 4
79 This option may be given up to three times, and specifies labels to be used in place of the corresponding file names in conflict reports\&. That is,
80 \fBgit\fR
81 \fBmerge\-file\fR
82 \fB\-L\fR
83 \fBx\fR
84 \fB\-L\fR
85 \fBy\fR
86 \fB\-L\fR
87 \fBz\fR
88 \fBa\fR
89 \fBb\fR
90 \fBc\fR
91 generates output that looks like it came from files x, y and z instead of from files a, b and c\&.
92 .RE
93 .PP
94 \-p
95 .RS 4
96 Send results to standard output instead of overwriting
97 \fI<current>\fR\&.
98 .RE
99 .PP
101 .RS 4
102 Quiet; do not warn about conflicts\&.
105 \-\-diff3
106 .RS 4
107 Show conflicts in "diff3" style\&.
110 \-\-zdiff3
111 .RS 4
112 Show conflicts in "zdiff3" style\&.
115 \-\-ours, \-\-theirs, \-\-union
116 .RS 4
117 Instead of leaving conflicts in the file, resolve conflicts favouring our (or their or both) side of the lines\&.
120 \-\-diff\-algorithm={patience|minimal|histogram|myers}
121 .RS 4
122 Use a different diff algorithm while merging\&. The current default is "myers", but selecting more recent algorithm such as "histogram" can help avoid mismerges that occur due to unimportant matching lines (such as braces from distinct functions)\&. See also
123 \fBgit-diff\fR(1)
124 \fB\-\-diff\-algorithm\fR\&.
126 .SH "EXAMPLES"
128 \fBgit\fR \fBmerge\-file\fR \fBREADME\&.my\fR \fBREADME\fR \fBREADME\&.upstream\fR
129 .RS 4
130 combines the changes of README\&.my and README\&.upstream since README, tries to merge them and writes the result into README\&.my\&.
133 \fBgit\fR \fBmerge\-file\fR \fB\-L\fR \fBa\fR \fB\-L\fR \fBb\fR \fB\-L\fR \fBc\fR \fBtmp/a123\fR \fBtmp/b234\fR \fBtmp/c345\fR
134 .RS 4
135 merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels
136 \fBa\fR
138 \fBc\fR
139 instead of
140 \fBtmp/a123\fR
142 \fBtmp/c345\fR\&.
145 \fBgit\fR \fBmerge\-file\fR \fB\-p\fR \fB\-\-object\-id\fR \fBabc1234\fR \fBdef567\fR \fB890abcd\fR
146 .RS 4
147 combines the changes of the blob abc1234 and 890abcd since def567, tries to merge them and writes the result to standard output
149 .SH "GIT"
151 Part of the \fBgit\fR(1) suite