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 c generates output that looks like it came from files x, y and z instead of from files a, b and c. 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 --diff3 and --zdiff3 options default to the value of the merge.conflictStyle configuration variable (see git-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 also git-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