Use BeyondCompare to see difference between files in GIT Use BeyondCompare to see difference between files in GIT git git

Use BeyondCompare to see difference between files in GIT


This link tells the way to set up BeyondComapre as the diff tool in git

git config --global diff.tool bc3git config --global difftool.bc3.path "c:/program files/beyond compare 3/bcomp.exe"

To launch a diff using Beyond Compare, use the command "git difftool foofile.txt".


I'll just elaborate more on @SharpCoder's accepted answer.

The first command that we run is as below:

git config --global diff.tool bc3

The above command creates below entry in .gitconfig found in %userprofile% directory:

[diff]    tool = bc3

Then you run below command (Running this command is redundant in this particular case and is required in some specialized cases only. You will know it in a short while):

git config --global difftool.bc3.path "c:/program files/beyond compare 3/bcomp.exe"

Above command creates below entry in .gitconfig file:

[difftool "bc3"]    path = c:/program files/Beyond Compare 3/bcomp.exe

The thing to know here is the key bc3. This is a well known key to git corresponding to a particular version of well known comparison tools available in market (bc3 corresponds to 3rd version of Beyond Compare tool). If you want to see all pre-defined keys just run git difftool --tool-help command on git bash. It returns below list:

vimdiffvimdiff2vimdiff3araxisbcbc3codecomparedeltawalkerdiffmergediffuseecmergeemergeexamdiffgvimdiffgvimdiff2gvimdiff3kdiff3komparemeldopendiffp4mergetkdiffwinmergexxdiff

You can use any of the above keys or define a custom key of your own. If you want to setup a new tool altogether(or a newly released version of well-known tool) which doesn't map to any of the keys listed above then you are free to map it to any of keys listed above or to a new custom key of your own.

What if you have to setup a comparison tool which is

  • Absolutely new in market

OR

  • A new version of an existing well known tool has got released which is not mapped to any pre-defined keys in git?

Like in my case, I had installed beyond compare 4. beyond compare is a well-known tool to git but its version 4 release is not mapped to any of the existing keys by default. So you can follow any of the below approaches:

  1. I can map beyond compare 4 tool to already existing key bc3 which corresponds to beyond compare 3 version. I didn't have beyond compare version 3 on my computer so I didn't care. If I wanted I could have mapped it to any of the pre-defined keys in the above list also e.g. examdiff.

    If you map well known version of tools to appropriate already existing/well-known key then you would not need to run the second command as their install path is already known to git.

    For e.g. if I had installed beyond compare version 3 on my box then having below configuration in my .gitconfig file would have been sufficient to get going:

    [diff]tool = bc3

    But if you want to change the default associated tool then you end up mentioning the path attribute separately so that git gets to know the path from where you new tool's exe has to be launched. Here is the entry which foxes git to launch beyond compare 4 instead. Note the exe's path:

    [difftool "bc3"]path = c:/program files/Beyond Compare 4/bcomp.exe
  2. Most cleanest approach is to define a new key altogether for the new comparison tool or a new version of an well known tool. Like in my case I defined a new key bc4 so that it is easy to remember. In such a case you have to run two commands in all but your second command will not be setting path of your new tool's executable. Instead you have to set cmd attribute for your new tool as shown below:

    git config --global diff.tool bc4git config --global difftool.bc4.cmd "\"C:\\Program Files\\Beyond Compare 4\\bcomp.exe\" -s \"\$LOCAL\" -d \"\$REMOTE\""

    Running above commands creates below entries in your .gitconfig file:

    [diff]tool = bc4[difftool "bc4"]cmd = \"C:\\Program Files\\Beyond Compare 4\\bcomp.exe\" -s \"$LOCAL\" -d \"$REMOTE\"

I would strongly recommend you to follow approach # 2 to avoid any confusion for yourself in future.


Beyond compare is a mergetool and a diff tool. I have it for both operations anyway. When I want to see the differences between my current state and the last commited I write

    git diff 

for a fast text output and small changes and

   git difftool

for changes in multiple files. Also keep in mind that you can do a git log, copy the first part of your commit's hash value and do a

   git difftool (commit1) (commit2)

and compare all the files one after another (very productive and useful)