James Simm
James Simm
Head of Engineering
Manchester

Engineering

Using meld as a Git merge tool on Windows

Recently Windows 10 has updated with the “Creators Update” which, while I know you’re all really excited for the 3D mode for MS Paint, also includes a whole host of updates for the Windows Subsystem for Linux, including Windows Linux interoperability.

What does this mean? Well, among other things, you can now launch windows programs from your bash command line. One nice way we can make use of this is triggering a nice gui-based merge tool from the git command line.

Personally, I quite like Meld which is a nice free diffing tool for text.

So to launch Meld as your diffing tool for git merges you simply need to do the following:

1) First, create a script to pass things over to meld:

nano meld

#!/bin/bash

/mnt/c/Program\ Files\ \(x86\)/Meld/Meld.exe [email protected]

This just launches the program and passes over any arguments using

the[email protected]

2) Copy over the new script to your bin directory with:

sudo cp meld /bin/

This allows us to launch it from wherever we want.

3) Then in your .Gitconfig you just need:

[merge]

        tool = meld

[mergetool "meld"]

       cmd = meld --diff \"$BASE\" \"$LOCAL\" \"$REMOTE\" --output \"$MERGED\"

When you then launch the command using

git mergetool

in a repository that needs merges, it’ll automatically launch meld and pass it all the files.

More?

Questions?

Head of UX Design & Insights

Kyle Cassidy

Stay in touch!

Personalize your experience

We use functional cookies to make the website work properly, analytical cookies to measure your behavior and marketing cookies for ads- and content personalization. We collect data on how you use our website to make our website easier to use, but also to tailor or personalize communication in advertisements, on our website or apps. Data collected through marketing cookies is also shared with third parties. By clicking accept you agree to this. More information? Read our cookie policy.