Visually diff two branches using WinMerge

Sometimes you need to diff two branches and your source control system isn’t the right tool for the job. One option is to use WinMerge to diff the branch folders and then look at the diffs visually in the UI. I’ll show how to do that.

1 – Example – Old Branch and New Branch

Here’s a simple example of two branches – named Old Branch and New Branch.

Old Branch

WinMerge - Project files in "Old Branch" folder

New Branch

WinMerge - Project files in "New Branch" folder

In the new branch I made the following changes:

  1. Program.cs – extracted out the StoreRepository class to its own file
  2. StoreRepository.cs – added this new file
  3. Store.cs – removed unused references

2 – Install WinMerge

Download and install WinMerge from Pick whatever version is right for you.

3 – Select the Old Branch and New Branch to diff them

WinMerge - Selecting folders to compare
  • Left=Old Branch
  • Right=New Branch
  • Make sure to check Include Subfolders.

4 – Analyze the diffs

WinMerge - Comparison results for files in both directories (no changes, changes, and new files)

Hide the ones with no changes

If you’re dealing with a large number of files, it helps to hide the files with no changes.

  1. Right-click all the files with “Text files are identical”
  2. Click Hide Items
    WinMerge - hiding files that didn't change

View the diffs and merge them

  1. Right-click the file -> Compare
    WinMerge - diffing files that changed
  2. Use hotkeys to select the diff and copy it to the right
    • Alt-Down = select the next diff
    • Alt-Right = copy the changes from the left to the right
      WinMerge - Looking at file diffs
  3. Because the files are now the same, it’ll show this prompt. Click OK.
    WinMerge - prompt saying they're the same
  4. Ctrl-S to save the merged file

View the new files

  1. Right-click the file that says “Right only:…”
  2. Click Open Right -> with External Editor
    WinMerge - Selecting new files

This will open the file in Notepad. You can verify the file is what you expected, or make edits if there’s any changes needed.

Text contents of new file

Leave a Comment