How to setup kdiff3 as a git mergetool in WSL

I have been developing in windows WSL recently and I encountered a problem, when in case of a merge conflict how to use a good GUI mergetool.

I really like the kdiff3 on windows, so here is how you can set it up as a default mergetool in Git

  1. Download and install the latest version of kdiff3 for windows fromhere http://kdiff3.sourceforge.net/
  2. Setup kdiff3 in your path, so that WSL can easily find it
    1. Click on start button and search env and open “Edit the system environment variables”

2. Then click on Enviroment Variables button

3. Then select Path and click Edit button

4. Then click New and Add the Path where KDiff3 is installed under Program Files

Setting up default merge tool in Git

Open WSL terminal and type in the following commands to set kdiff3 as the default

That’s it! Now if you run git mergetool command, kidff3 will open up as your default merge tool.