GIT-MERGE-FILE(1)
π GIT-MERGE-FILE(1) β the girlies' guide to three-way merging
okay so bestie, this is a Git Manual page for git-merge-file, and honestly? it's the quiet little icon of the merge world. it doesn't get the hype of git merge but it's out here doing the actual work. let's get into it π«Ά
β¨ NAME β¨
git-merge-file β run a three-way file merge. yes, three files. it's giving thruple energy and it slays.
π¦ SYNOPSIS π¦
git merge-file [-L <current-name> [-L <base-name> [-L <other-name>]]]
[--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=<n>]
[--[no-]diff3] [--object-id] <current> <base> <other>
like, look at all those brackets. she's flexible. she's got options. π
π DESCRIPTION π
so you hand her three files β <current>, <base>, and <other> β and git merge-file takes all the changes that lead from <base> to <other> and incorporates them into <current>. the result ordinarily goes into <current>. main character behavior tbh.
she's literally built for combining separate changes to an original. picture it: <base> is the original, and both <current> and <other> are modifications of <base>. git merge-file combines both changes. both! at once! we love a multitasker π
now the messy part. a conflict happens if both <current> and <other> have changes in a common segment of lines. like two people editing the same paragraph in a shared doc. awkward.
if a conflict is found, git merge-file normally outputs a warning and brackets the conflict with lines containing <<<<<<< and >>>>>>> markers. a typical conflict will look like this:
<<<<<<< A
lines in file A
=======
lines in file B
>>>>>>> B
if there are conflicts, you β yes you, bestie β should edit the result and delete one of the alternatives. it's giving "choose your fighter" π
but wait β when --ours, --theirs, or --union option is in effect, these conflicts are resolved favouring lines from <current>, lines from <other>, or lines from both respectively. no editing required, she just picks for you. icon behavior. and the length of the conflict markers can be given with the --marker-size option. custom markers!! aesthetic!! β¨
if --object-id 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. same vibe, blob-flavoured π
the exit value tea β β this is important so listen up:
- the exit value of this program is negative on error
- otherwise it's the number of conflicts (truncated to 127 if there are more than that many conflicts)
- if the merge was clean, the exit value is
0β slay, no notes
and for the lore girlies: git merge-file is designed to be a minimal clone of RCS merge. that is, it implements all of RCS merge's functionality which is needed by git(1). she's a faithful recreation, a tribute, a cover that ate the original π₯
β OPTIONS β
the full menu, no skips, no cuts. get comfy π
--object-idβ 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. so like, you gotta be inside a repo, no exceptions.
if the -p 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. juicy π
-L <label>β 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,git merge-file -L x -L y -L z a b cgenerates output that looks like it came from filesx,yandzinstead of from filesa,bandc. it's a glow-up for your filenames, fr fr β¨-pβ send results to standard output instead of overwriting<current>. non-destructive queen π«Ά-qβ quiet; do not warn about conflicts. she's seen things. she's not gonna talk about it π--diff3β show conflicts in"diff3"style.--zdiff3β show conflicts in"zdiff3"style. (yes there's a z, yes it's a whole thing)
the--diff3and--zdiff3options default to the value of themerge.conflictStyleconfiguration variable (seegit-config(1)). so your config is quietly making decisions for you. iykyk π
--ours,--theirs,--unionβ instead of leaving conflicts in the file, resolve conflicts favouring our (or their or both) side of the lines. pick a side, any side π--diff-algorithm={patience|minimal|histogram|myers}β 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 alsogit-diff(1)--diff-algorithm. upgrade your algorithm, upgrade your life π§
πΈ EXAMPLES πΈ
real scenarios, real slay. these are verbatim bestie, don't touch π
git merge-file README.my README README.upstream
combines the changes of README.my and README.upstream since README, tries to merge them and writes the result into README.my.
git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345
merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels a and c instead of tmp/a123 and tmp/c345.
git merge-file -p --object-id abc1234 def567 890abcd
combines the changes of the blob abc1234 and 890abcd since def567, tries to merge them and writes the result to standard output.
π GIT π
part of the git(1) suite. one of the family. the nepo baby that actually earned it π
okay that's the whole page, go forth and merge three-way like the icon you are πβ¨
β with love, from the git crew Β· Git 2.56.0 Β· dated 2026-09-27 Β· mwah π
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms