Skip to main content

Beyond Compare

Beyond Compare is a diff/merge tool available for Windows, Linux as well as Mac OS. Beyond requires a paid license. Beyond compared is reasonably priced and fair. A license is not tied to a specific platform and is not subscription-based. Considering the time saved resolving merge conflicts makes purchasing a license worth while.

However, when keeping source code inside of the windows subsystem for linux some extra configuration is required to utilise Beyond Compare running on the Windows side.

More details in this forum post: Updated in Windows-WSL

Configuring the Windows Subsystem for Linux (WSL)

Generally speaking, I maintain, compile and run all my projects inside of the windows subsystem for Linux (WSL). However, since I run Windows on my developer machine GUI tools such as Beyond Compare require the Windows versions of these tools.

In the case of integrating with the Linux GIT CLI this can be problematic as the windows application needs to be aware that the code itself is stored inside of the WSL.

The following configuration allows integrating the git "diff tool" and "merge tool" commands with the Windows version of "Beyond Compare". The configuration affords the ability to initiate a diff/merge session of files in the WSL using the windows version of Beyond Compare. Diffing and Merging with this setup works expected when git commands are used to launch "Beyond Compare" from the WSL.

Installation on the Windows Side

  1. Install Beyond Compare

  2. Add the beyond compare folder to the windows path environment variable.

  3. Reboot Windows to pick up the environment variable changes.

  4. Confirm that typing "bcomp.exe" inside of a power shell opens beyond compare in windows.

  5. Confirm that typing "bcomp.exe" inside of a the WSL also opens beyond compare in windows.


Configuration within the WSL

git config --global diff.tool bc
git config --global difftool.prompt false
git config --global difftool.bc trustExitCode true
git config --global merge.tool bc
git config --global mergetool.bc trustExitCode true

# This is the magic that allows using the windows beyond compare installation as the difftool for
# the linux git difftool and git mergetool commands.
# Note: The beyond compare installation folder (where the BComp.exe is located) must be added to the windows
# path.
git config --global difftool.bc.cmd 'BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)"'
git config --global mergetool.bc.cmd 'BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)"'

Executing the git difftool and git mergetool commands will now open Beyond Compare in windows and map the diff paths in such a way that beyond compare correctly presents the file and folder differences stored insisde of the WSL.


Working with Beyond Compare

Beyond compare show our three sources of truth (Copy A, Base, Copy B) in the top three panes, with the centre pane showing the base view.