Merge engine you can drive on arbitrary files outside a repo.
git merge-file performs a 3-way merge on three arbitrary files (current, base, other) and writes the result. It's Git's merge engine exposed for scripts and external diff tools.
Think diff3 with conflict markers and Git semantics. No repo required; you point it at three paths and it produces a merged file plus an exit code equal to the number of conflicts.
git merge-file [-L <cur> [-L <base> [-L <other>]]] [--ours|--theirs|--union]
[-p] [-q] [--marker-size=<n>] [--diff-algorithm=<algo>]
<current-file> <base-file> <other-file>| Flag | What it does |
|---|---|
-p | Write the merged result to stdout instead of overwriting <current-file>. |
-q | Quiet: suppress conflict warnings on stderr. |
-L <name> | Label for current/base/other (repeat up to 3x); shows up in conflict markers. |
--ours | On conflict, take the current side; no markers emitted. |
--theirs | On conflict, take the other side; no markers emitted. |
--union | Concatenate both sides on conflict; no markers, but may produce nonsense. |
--marker-size=<n> | Change the length of <<<<<<< markers (default 7). |
--diff-algorithm=<algo> | Pick myers, minimal, patience, or histogram. |
git merge-file -L mine -L base -L theirs cur.txt base.txt other.txtgit merge-file -p cur.txt base.txt other.txtgit merge-file --ours cur.txt base.txt other.txtgit merge-file --diff-algorithm=histogram cur.c base.c other.c&& chains misbehave.Hit each option, then Check answers. Score is recorded; Next is always open.