GPL-2.0-only licensed by Eyal Lotem
Maintained by [email protected]
This version can be pinned in stack with:git-mediate-1.2.0@sha256:2dd1789f630e31589fcc99c6d50f4184ffce39f52ede917868940d499567eb12,3767

Module documentation for 1.2.0

There are no documented modules for this package.

git-mediate Hackage version homebrew

Introduction

Handling conflicts is difficult!

One useful way to handle them, is to use git’s {z,}diff3 conflict style:

git config --global merge.conflictstyle zdiff3

And then when you get a conflict, it looks like:

Unconflicted stuff

<<<<<<< HEAD
Version A changes
|||||||
Base version
======= Version B
Version B changes
>>>>>>>

More unconflicted stuff here

Then you are supposed to manually merge the useful changes in the top and bottom parts, relative to the base version.

A useful way to do this is to figure out which of the changes (Version A or Version B) is a simpler change.

Perhaps one of the versions just added a small comment above the code section:

Unconflicted stuff

<<<<<<< HEAD
Added a comment here
BASE
|||||||
BASE
======= Version B
BASE and complex changes here
>>>>>>>

More unconflicted stuff here

One easy thing to do, mechanically, is to apply the simple change to the other 2 versions. Thus, it becomes:

Unconflicted stuff

<<<<<<< HEAD
Added a comment here
BASE
|||||||
Added a comment here
BASE
======= Version B
Added a comment here
BASE and complex changes here
>>>>>>>

More unconflicted stuff here

Now, you can run this little utility: git-mediate, which will see the conflict has become trivial (only one side changed anything) and select that side appropriately.

When all conflicts have been resolved in a file, “git add” will be used on it automatically.

Simpler case

You might just resolve the conflicts manually and remove the merge markers from all of the conflicts.

In such a case, just run git-mediate, and it will “git add” the file for you.

Installation

Using package managers

Using haskell-stack

  1. Install haskell stack
  2. Run: stack install git-mediate

From sources

Clone it:

git clone https://github.com/Peaker/git-mediate
cd git-mediate

Option #1: Build & install using stack: stack install (make sure you installed haskell stack)

Option #2: Build & install using cabal: cabal install (make sure ~/.cabal/bin is in your $PATH)

Use

Call the git-mediate from a git repository with conflicts.

Additional features

Open editor

You can use the -e flag to invoke your $EDITOR on every conflicted file that could not be automatically resolved.

Show conflict diffs

Sometimes, the conflict is just a giant block of incomprehensible text next to another giant block of incomprehensible text.

You can use the -d flag to show the conflict in diff-from-base form. Then, you can manually apply the changes you see in both the base and wherever needed, and use git-mediate again to make sure you’ve updated everything appropriately.

License

Copyright (C) 2014-2024 Eyal Lotem

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License only.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Changes

1.2.0 / 2026.08.19

  • Add optional automatic resolution of indentation-only conflicts
  • Enable splitting conflicts at tilde markers by default
  • Fix status reporting for split conflicts
  • Prefer Git’s zdiff3 conflict style while continuing to accept diff3
  • Avoid opening the editor when no unresolved conflicts remain

1.1.0 / 2024.09.20

  • --split-markers option to help users split large conflicts to smaller parts
  • --lines-added-around option to auto-resolve conflicts of line added from different sides
  • Command-line options are are also parsed from the GIT_MEDIATE_OPTIONS environment variables
  • Can disable auto-resolution with the --no-trivial, --no-reduce, and --no-line-endings flags
  • Improved --editor support for VS Code and Xcode
  • Fixed handling of filenames containing spaces and special characters

1.0.9 / 2023.07.25

  • Do not warn when git is set to use zdiff3 conflict style
  • Resolve line ending conventions changes (i.e changes from Unix/Windows line endings)
  • Preserve file modes when resolving conflicts (i.e executable scripts remain executable)
  • Handle changes in git status formatting for files in spaces in their names
  • --context option for -d mode to control size of context shown around diff
  • Fixed parsing of conflicts with nested recursive conflicts
  • --editor goes to the location of the first conflict in the file

1.0.8.1 / 2020.10.13

  • First release on Debian (entered Debian unstable at 2023.07.20)
  • Build maintenance (anti-bitrot)

1.0.6 / 2020.01.07

  • --merge-file option to merge specific file, even if file is not marked as conflicted
  • Reduce add/add conflicts with matching prefix/suffix lines
  • Add support for --untabify

1.0.5 / 2018.07.24

  • Windows compatibility fixes

1.0.1 / 2018.07.24

  • Conflict headers for -d option (i.e “### Conflict 3 of 7”)
  • Improved error message when not running inside a git repository

1.0 / 2016.12.20

  • Renamed to git-mediate
  • First release on Hackage
  • Add --version flag

0.3.2.4 / 2016.12.20

  • Reduce conflicts when first or last lines match in all parts

0.3.2.1 / 2015.12.25

  • --diff2 option to dump diffs in diff2 format
  • Fix bug in modify/delete conflicts when not running from the repo’s root

0.3.1.2 / 2015.09.20

  • Better error reporting for conflict parsing errors

0.3.1.1 / 2015.09.01

  • Support modify/delete conflicts

0.3.0.3 / 2015.08.16

  • -d option also prints the diffs markers
  • Support add/add conflicts
  • Fixed bug with submodule conflicts

0.3.0.1 / 2015.06.06

  • Detect git using diff2 conflict style and add -s option to switch to diff3 style
  • Fixed bug with filenames containing spaces

0.2.0.2 / 2015.02.03

  • Support for terminals without color

0.2.0.1 / 2015.01.12

  • Don’t keep .bk backups files for content before resolution

0.2 / 2014.12.18

  • -d option for displaying the remaining conflicts

0.1.0.1 / 2014.12.10

  • Conflict also resolves if both sides match (regardless of base also matching)

Development started / 2014.12.1

  • Tool developed started originally as “resolve-trivial-conflicts”