1

We can use git's diff tool without git repos with git diff --no-index <FILE-A> <FILE-B>.

Is there a similar command for running git's merge algorithm given three input files ("ours", base & "theirs")? And specifically it should output the "diff3" style (seeing the "base" in the conflict is essential)

I understand that it couldn't be as smart as git's recursive merge strategy but I would be very satisfied with something basic like the "resolve" strategy.

yairchu
  • 23,680
  • 7
  • 69
  • 109
  • 1
    https://linux.die.net/man/1/merge – phd Oct 26 '20 at 14:51
  • @phd I didn't find a quick way to install this on my macOS setup, but reading the docs it appears that it's not in git's diff3 style (which indeed I didn't explcitly ask for in my question - I'll correct it) – yairchu Oct 26 '20 at 15:09

1 Answers1

3
git merge-file -p --diff3 ours base theirs
yairchu
  • 23,680
  • 7
  • 69
  • 109
jthill
  • 55,082
  • 5
  • 77
  • 137
  • Thanks! I've accepted and edited the answer to add the `-p` parameter to output the result on standard output (otherwise it isn't clear where it goes) – yairchu Oct 26 '20 at 15:52
  • 1
    @yairchu: without `-p`, `git merge-file` writes the result back to the first named file (`ours` here). – torek Oct 26 '20 at 18:19