As mentioned in the GIT documentation, you can set the environment variable GIT_EXTERNAL_DIFF to use a custom diff utility. Try doing "set GIT_EXTERNAL_DIFF=echo" and running a "git diff" command to see how GIT_EXTERNAL_DIFF works.

One limitation of this technique is that GIT launches the diff utility program once for every file modified. What this means is that you do not get to see the list of all files changed upfront (if you want to see how many files have changed, etc), and are also forced to review the files in the order GIT chooses. If you want to see all the test files first for example, or if you need to go back to a file you have already diffed, you have to start the "git diff" command all over again. Also, if you want to end the review half way through, you cannot do that easily and are forced to manually close the diff program multiple times until the "git diff" command terminates.

Luckily, there is a simple solution to this. You can use a simple script. See GitDiff.bat (and GitDiff.rb). The arguments to the script are the same as "git diff". However, it will show you a diff of two folders, one with the old version of the files and one with the new version of the files. You can review the files in the order you chose...

Here is a screenshot using Beyond Compare as the diffing tool. The window at the top is the main window showing the list of files. The two windows at the bottom are diffs of two of the changed files.

GitDiff

 

Setup instructions:

  • Copy GitDiff.bat and GitDiff.rb to somewhere in your path
  • Make sure that ruby.exe is in the path
  • Go to a folder in a GIT repo
  • GitDiff.bat <old-sha> <new-sha>