Innovative Computer Solutions,
Development & Technical Support

07975 997026 • enquiries[delete-me]@[delete-me]

User Tools

Site Tools


Using WinMerge with Git

After installing GitHub for Windows, the default Merge Tool is configured as Beyond Compare (a commercial file comparison package). WinMerge is also an excellent tool for comparing file differences under Windows, and has the benefit of being free.

Configuring Git to use WinMerge is very straightforward…

* First, download WinMerge ( and install it as normal.

* I am assuming you already have GitHub for Windows installed and configured, but if not you can find it here: - come back to these instructions when you are more familiar with GitWin.

I am using the portable version of WinMerge, which I have stored in e:\apps\WinMergePortable\WinMergePortable.exe and these instructions use that. For a conventional install of WinMerge, just change the path to the file. Tip: make a note of the full drive and file path as you will need to enter it below.

* Open up GitWin and open any repository you have created * Click the 'cog' icon in the top right corner

  • On the cog menu, choose 'Open a shell here'
  • (Alternatively, in the Windows Start Menu for GitHub, Inc you can click the 'Git Shell' shortcut)

It doesn't matter which repository you choose to run the shell for, as we are setting global settings below that apply to all repositories.

MergeTool or DiffTool

Git uses two tools which can be slightly confusing for some.

* The difftool is like using a 'Read Only' version of WinMerge. It doesn't let you change anything, it just shows you the difference between two files. * The mergetool is the tool that lets you fix any file conflicts when merging between branches in Git. In most cases it is the 'mergetool' that people want to configure to gain a visual way of fixing merge conflicts, so we will do that first.

Configure WinMerge as the MERGE TOOL

In the Shell window, we need to run the following two commands individually:

git config --global merge.tool winmerge
git config --global --replace mergetool.winmerge.cmd "e:/apps/WinMergePortable/WinMergePortable.exe -e -ul -ur -dl \"Base: $MERGED\" -dr \"Mine: $REMOTE\" $MERGED $REMOTE"

In the first command, we are setting a Git variable named merge.tool to the value winmerge. This tells Git to run winmerge when the merge.tool is called.

In the second line we are defining the command that should be executed when the merge.tool is called. Note the following in this line above:

* We use forward slashes / in the path, NOT back slashes, because back slashes are treated as 'escape' symbols;

* The \” entries around the text strings are creating 'escaped' apostrophes so that they are not confused with the apostrophes around the entire command;

* We are using the Git $MERGED and $REMOTE variables to indicate the files to be compared/merged.

  • The $MERGED variable contains the file created by Git when it found a conflict during the merge attempt;
  • The $REMOTE variable contains the file that you are attempting to merge into the current repository

Now, when you get a response similar to the following…

Automatic merge failed; fix conflicts and then commit the result.

… you can run git mergetool to try and resolve the conflicts visually.

Configure WinMerge as the DIFF TOOL

In a very similar manner to above, we can use WinMerge to show us the difference between two files. In the Shell window, this time run the following two commands individually:

git config --global diff.tool winmerge
git config --global difftool.winmerge.cmd "e:/apps/WinMergePortable/WinMergePortable.exe -e -ul -ur -wl -wr -dl \"Local: $LOCAL\" -dr \"Remote: $REMOTE\" $LOCAL $REMOTE"

You will notice a few slight differences:

* We are defining the diff.tool variables this time; * We have added -wl and -wr to the command line, which are WinMerge's options to make the left and right files 'Read-Only'; * We are using the $LOCAL and $REMOTE file variables this time (there is no $MERGED variable as we are not merging across branches);

Now you can run the following command to compare two files:

git difftool <branch1> <branch2> -- <filename to compare>


hi, just a test, plz delete

1 | 11/11/2016 09:08 |

blog/2014/06/using-winmerge-with-git.txt · Last modified: 02/06/2014 20:06 by harpanet